diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0b26bf2..bb1b2d3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,8 +32,9 @@ jobs: curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1 - name: Install dependencies run: poetry install + - name: Test - run: poetry run pytest . + run: poetry run pytest ./tests/custom/ publish: needs: [compile, test] diff --git a/poetry.lock b/poetry.lock index d0145b2..a257797 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,14 +1,14 @@ -# This file is automatically @generated by Poetry 1.8.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. [[package]] name = "annotated-types" -version = "0.6.0" +version = "0.7.0" description = "Reusable constraint types to use with typing.Annotated" optional = false python-versions = ">=3.8" files = [ - {file = "annotated_types-0.6.0-py3-none-any.whl", hash = "sha256:0641064de18ba7a25dee8f96403ebc39113d0cb953a01429249d5c7564666a43"}, - {file = "annotated_types-0.6.0.tar.gz", hash = "sha256:563339e807e53ffd9c267e99fc6d9ea23eb8443c08f112651963e24e22f84a5d"}, + {file = "annotated_types-0.7.0-py3-none-any.whl", hash = "sha256:1f02e8b43a8fbbc3f3e0d4f0f4bfc8131bcb4eebe8849b8e5c773f3a1c582a53"}, + {file = "annotated_types-0.7.0.tar.gz", hash = "sha256:aff07c09a53a08bc8cfccb9c85b05f1aa9a2a6f23728d790723543408344ce89"}, ] [package.dependencies] @@ -16,13 +16,13 @@ typing-extensions = {version = ">=4.0.0", markers = "python_version < \"3.9\""} [[package]] name = "anyio" -version = "4.3.0" +version = "4.4.0" description = "High level compatibility layer for multiple asynchronous event loop implementations" optional = false python-versions = ">=3.8" files = [ - {file = "anyio-4.3.0-py3-none-any.whl", hash = "sha256:048e05d0f6caeed70d731f3db756d35dcc1f35747c8c403364a8332c630441b8"}, - {file = "anyio-4.3.0.tar.gz", hash = "sha256:f75253795a87df48568485fd18cdd2a3fa5c4f7c5be8e5e36637733fce06fed6"}, + {file = "anyio-4.4.0-py3-none-any.whl", hash = "sha256:c1b2d8f46a8a812513012e1107cb0e68c17159a7a594208005a57dc776e1bdc7"}, + {file = "anyio-4.4.0.tar.gz", hash = "sha256:5aadc6a1bbb7cdb0bede386cac5e2940f5e2ff3aa20277e991cf028e0585ce94"}, ] [package.dependencies] @@ -38,13 +38,13 @@ trio = ["trio (>=0.23)"] [[package]] name = "certifi" -version = "2024.2.2" +version = "2024.6.2" description = "Python package for providing Mozilla's CA Bundle." optional = false python-versions = ">=3.6" files = [ - {file = "certifi-2024.2.2-py3-none-any.whl", hash = "sha256:dc383c07b76109f368f6106eee2b593b04a011ea4d55f652c6ca24a754d1cdd1"}, - {file = "certifi-2024.2.2.tar.gz", hash = "sha256:0569859f95fc761b18b45ef421b1290a0f65f147e92a1e5eb3e635f9a5e4e66f"}, + {file = "certifi-2024.6.2-py3-none-any.whl", hash = "sha256:ddc6c8ce995e6987e7faf5e3f1b02b302836a0e5d98ece18392cb1a36c72ad56"}, + {file = "certifi-2024.6.2.tar.gz", hash = "sha256:3cd43f1c6fa7dedc5899d69d3ad0398fd018ad1a17fba83ddaf78aa46c747516"}, ] [[package]] @@ -60,13 +60,13 @@ files = [ [[package]] name = "exceptiongroup" -version = "1.2.0" +version = "1.2.1" description = "Backport of PEP 654 (exception groups)" optional = false python-versions = ">=3.7" files = [ - {file = "exceptiongroup-1.2.0-py3-none-any.whl", hash = "sha256:4bfd3996ac73b41e9b9628b04e079f193850720ea5945fc96a08633c66912f14"}, - {file = "exceptiongroup-1.2.0.tar.gz", hash = "sha256:91f5c769735f051a4290d52edd0858999b57e5876e9f85937691bd4c9fa3ed68"}, + {file = "exceptiongroup-1.2.1-py3-none-any.whl", hash = "sha256:5258b9ed329c5bbdd31a309f53cbfb0b155341807f6ff7606a1e801a891b29ad"}, + {file = "exceptiongroup-1.2.1.tar.gz", hash = "sha256:a4785e48b045528f5bfe627b6ad554ff32def154f42372786903b7abcfe1aa16"}, ] [package.extras] @@ -130,13 +130,13 @@ socks = ["socksio (==1.*)"] [[package]] name = "idna" -version = "3.6" +version = "3.7" description = "Internationalized Domain Names in Applications (IDNA)" optional = false python-versions = ">=3.5" files = [ - {file = "idna-3.6-py3-none-any.whl", hash = "sha256:c05567e9c24a6b9faaa835c4821bad0590fbb9d5779e7caa6e1cc4978e7eb24f"}, - {file = "idna-3.6.tar.gz", hash = "sha256:9ecdbbd083b06798ae1e86adcbfe8ab1479cf864e4ee30fe4e46a003d12491ca"}, + {file = "idna-3.7-py3-none-any.whl", hash = "sha256:82fee1fc78add43492d3a1898bfa6d8a904cc97d8427f683ed8e798d07761aa0"}, + {file = "idna-3.7.tar.gz", hash = "sha256:028ff3aadf0609c1fd278d8ea3089299412a7a8b9bd005dd08b9f8285bcb5cfc"}, ] [[package]] @@ -152,49 +152,48 @@ files = [ [[package]] name = "mypy" -version = "1.9.0" +version = "1.0.1" description = "Optional static typing for Python" optional = false -python-versions = ">=3.8" +python-versions = ">=3.7" files = [ - {file = "mypy-1.9.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:f8a67616990062232ee4c3952f41c779afac41405806042a8126fe96e098419f"}, - {file = "mypy-1.9.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:d357423fa57a489e8c47b7c85dfb96698caba13d66e086b412298a1a0ea3b0ed"}, - {file = "mypy-1.9.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:49c87c15aed320de9b438ae7b00c1ac91cd393c1b854c2ce538e2a72d55df150"}, - {file = "mypy-1.9.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:48533cdd345c3c2e5ef48ba3b0d3880b257b423e7995dada04248725c6f77374"}, - {file = "mypy-1.9.0-cp310-cp310-win_amd64.whl", hash = "sha256:4d3dbd346cfec7cb98e6cbb6e0f3c23618af826316188d587d1c1bc34f0ede03"}, - {file = "mypy-1.9.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:653265f9a2784db65bfca694d1edd23093ce49740b2244cde583aeb134c008f3"}, - {file = "mypy-1.9.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:3a3c007ff3ee90f69cf0a15cbcdf0995749569b86b6d2f327af01fd1b8aee9dc"}, - {file = "mypy-1.9.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2418488264eb41f69cc64a69a745fad4a8f86649af4b1041a4c64ee61fc61129"}, - {file = "mypy-1.9.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:68edad3dc7d70f2f17ae4c6c1b9471a56138ca22722487eebacfd1eb5321d612"}, - {file = "mypy-1.9.0-cp311-cp311-win_amd64.whl", hash = "sha256:85ca5fcc24f0b4aeedc1d02f93707bccc04733f21d41c88334c5482219b1ccb3"}, - {file = "mypy-1.9.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:aceb1db093b04db5cd390821464504111b8ec3e351eb85afd1433490163d60cd"}, - {file = "mypy-1.9.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:0235391f1c6f6ce487b23b9dbd1327b4ec33bb93934aa986efe8a9563d9349e6"}, - {file = "mypy-1.9.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d4d5ddc13421ba3e2e082a6c2d74c2ddb3979c39b582dacd53dd5d9431237185"}, - {file = "mypy-1.9.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:190da1ee69b427d7efa8aa0d5e5ccd67a4fb04038c380237a0d96829cb157913"}, - {file = "mypy-1.9.0-cp312-cp312-win_amd64.whl", hash = "sha256:fe28657de3bfec596bbeef01cb219833ad9d38dd5393fc649f4b366840baefe6"}, - {file = "mypy-1.9.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:e54396d70be04b34f31d2edf3362c1edd023246c82f1730bbf8768c28db5361b"}, - {file = "mypy-1.9.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:5e6061f44f2313b94f920e91b204ec600982961e07a17e0f6cd83371cb23f5c2"}, - {file = "mypy-1.9.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:81a10926e5473c5fc3da8abb04119a1f5811a236dc3a38d92015cb1e6ba4cb9e"}, - {file = "mypy-1.9.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:b685154e22e4e9199fc95f298661deea28aaede5ae16ccc8cbb1045e716b3e04"}, - {file = "mypy-1.9.0-cp38-cp38-win_amd64.whl", hash = "sha256:5d741d3fc7c4da608764073089e5f58ef6352bedc223ff58f2f038c2c4698a89"}, - {file = "mypy-1.9.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:587ce887f75dd9700252a3abbc9c97bbe165a4a630597845c61279cf32dfbf02"}, - {file = "mypy-1.9.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:f88566144752999351725ac623471661c9d1cd8caa0134ff98cceeea181789f4"}, - {file = "mypy-1.9.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:61758fabd58ce4b0720ae1e2fea5cfd4431591d6d590b197775329264f86311d"}, - {file = "mypy-1.9.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:e49499be624dead83927e70c756970a0bc8240e9f769389cdf5714b0784ca6bf"}, - {file = "mypy-1.9.0-cp39-cp39-win_amd64.whl", hash = "sha256:571741dc4194b4f82d344b15e8837e8c5fcc462d66d076748142327626a1b6e9"}, - {file = "mypy-1.9.0-py3-none-any.whl", hash = "sha256:a260627a570559181a9ea5de61ac6297aa5af202f06fd7ab093ce74e7181e43e"}, - {file = "mypy-1.9.0.tar.gz", hash = "sha256:3cc5da0127e6a478cddd906068496a97a7618a21ce9b54bde5bf7e539c7af974"}, + {file = "mypy-1.0.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:71a808334d3f41ef011faa5a5cd8153606df5fc0b56de5b2e89566c8093a0c9a"}, + {file = "mypy-1.0.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:920169f0184215eef19294fa86ea49ffd4635dedfdea2b57e45cb4ee85d5ccaf"}, + {file = "mypy-1.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:27a0f74a298769d9fdc8498fcb4f2beb86f0564bcdb1a37b58cbbe78e55cf8c0"}, + {file = "mypy-1.0.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:65b122a993d9c81ea0bfde7689b3365318a88bde952e4dfa1b3a8b4ac05d168b"}, + {file = "mypy-1.0.1-cp310-cp310-win_amd64.whl", hash = "sha256:5deb252fd42a77add936b463033a59b8e48eb2eaec2976d76b6878d031933fe4"}, + {file = "mypy-1.0.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:2013226d17f20468f34feddd6aae4635a55f79626549099354ce641bc7d40262"}, + {file = "mypy-1.0.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:48525aec92b47baed9b3380371ab8ab6e63a5aab317347dfe9e55e02aaad22e8"}, + {file = "mypy-1.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c96b8a0c019fe29040d520d9257d8c8f122a7343a8307bf8d6d4a43f5c5bfcc8"}, + {file = "mypy-1.0.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:448de661536d270ce04f2d7dddaa49b2fdba6e3bd8a83212164d4174ff43aa65"}, + {file = "mypy-1.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:d42a98e76070a365a1d1c220fcac8aa4ada12ae0db679cb4d910fabefc88b994"}, + {file = "mypy-1.0.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:e64f48c6176e243ad015e995de05af7f22bbe370dbb5b32bd6988438ec873919"}, + {file = "mypy-1.0.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5fdd63e4f50e3538617887e9aee91855368d9fc1dea30da743837b0df7373bc4"}, + {file = "mypy-1.0.1-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:dbeb24514c4acbc78d205f85dd0e800f34062efcc1f4a4857c57e4b4b8712bff"}, + {file = "mypy-1.0.1-cp37-cp37m-win_amd64.whl", hash = "sha256:a2948c40a7dd46c1c33765718936669dc1f628f134013b02ff5ac6c7ef6942bf"}, + {file = "mypy-1.0.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:5bc8d6bd3b274dd3846597855d96d38d947aedba18776aa998a8d46fabdaed76"}, + {file = "mypy-1.0.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:17455cda53eeee0a4adb6371a21dd3dbf465897de82843751cf822605d152c8c"}, + {file = "mypy-1.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e831662208055b006eef68392a768ff83596035ffd6d846786578ba1714ba8f6"}, + {file = "mypy-1.0.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:e60d0b09f62ae97a94605c3f73fd952395286cf3e3b9e7b97f60b01ddfbbda88"}, + {file = "mypy-1.0.1-cp38-cp38-win_amd64.whl", hash = "sha256:0af4f0e20706aadf4e6f8f8dc5ab739089146b83fd53cb4a7e0e850ef3de0bb6"}, + {file = "mypy-1.0.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:24189f23dc66f83b839bd1cce2dfc356020dfc9a8bae03978477b15be61b062e"}, + {file = "mypy-1.0.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:93a85495fb13dc484251b4c1fd7a5ac370cd0d812bbfc3b39c1bafefe95275d5"}, + {file = "mypy-1.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5f546ac34093c6ce33f6278f7c88f0f147a4849386d3bf3ae193702f4fe31407"}, + {file = "mypy-1.0.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:c6c2ccb7af7154673c591189c3687b013122c5a891bb5651eca3db8e6c6c55bd"}, + {file = "mypy-1.0.1-cp39-cp39-win_amd64.whl", hash = "sha256:15b5a824b58c7c822c51bc66308e759243c32631896743f030daf449fe3677f3"}, + {file = "mypy-1.0.1-py3-none-any.whl", hash = "sha256:eda5c8b9949ed411ff752b9a01adda31afe7eae1e53e946dbdf9db23865e66c4"}, + {file = "mypy-1.0.1.tar.gz", hash = "sha256:28cea5a6392bb43d266782983b5a4216c25544cd7d80be681a155ddcdafd152d"}, ] [package.dependencies] -mypy-extensions = ">=1.0.0" +mypy-extensions = ">=0.4.3" tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} -typing-extensions = ">=4.1.0" +typing-extensions = ">=3.10" [package.extras] dmypy = ["psutil (>=4.0)"] install-types = ["pip"] -mypyc = ["setuptools (>=50)"] +python2 = ["typed-ast (>=1.4.0,<2)"] reports = ["lxml"] [[package]] @@ -210,24 +209,24 @@ files = [ [[package]] name = "packaging" -version = "24.0" +version = "24.1" description = "Core utilities for Python packages" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "packaging-24.0-py3-none-any.whl", hash = "sha256:2ddfb553fdf02fb784c234c7ba6ccc288296ceabec964ad2eae3777778130bc5"}, - {file = "packaging-24.0.tar.gz", hash = "sha256:eb82c5e3e56209074766e6885bb04b8c38a0c015d0a30036ebe7ece34c9989e9"}, + {file = "packaging-24.1-py3-none-any.whl", hash = "sha256:5b8f2217dbdbd2f7f384c41c628544e6d52f2d0f53c6d0c3ea61aa5d1d7ff124"}, + {file = "packaging-24.1.tar.gz", hash = "sha256:026ed72c8ed3fcce5bf8950572258698927fd1dbda10a5e981cdf0ac37f4f002"}, ] [[package]] name = "pluggy" -version = "1.4.0" +version = "1.5.0" description = "plugin and hook calling mechanisms for python" optional = false python-versions = ">=3.8" files = [ - {file = "pluggy-1.4.0-py3-none-any.whl", hash = "sha256:7db9f7b503d67d1c5b95f59773ebb58a8c1c288129a88665838012cfb07b8981"}, - {file = "pluggy-1.4.0.tar.gz", hash = "sha256:8c85c2876142a764e5b7548e7d9a0e0ddb46f5185161049a79b7e974454223be"}, + {file = "pluggy-1.5.0-py3-none-any.whl", hash = "sha256:44e1ad92c8ca002de6377e165f3e0f1be63266ab4d554740532335b9d75ea669"}, + {file = "pluggy-1.5.0.tar.gz", hash = "sha256:2cffa88e94fdc978c4c574f15f9e59b7f4201d439195c3715ca9e2486f1d0cf1"}, ] [package.extras] @@ -236,18 +235,18 @@ testing = ["pytest", "pytest-benchmark"] [[package]] name = "pydantic" -version = "2.6.4" +version = "2.7.4" description = "Data validation using Python type hints" optional = false python-versions = ">=3.8" files = [ - {file = "pydantic-2.6.4-py3-none-any.whl", hash = "sha256:cc46fce86607580867bdc3361ad462bab9c222ef042d3da86f2fb333e1d916c5"}, - {file = "pydantic-2.6.4.tar.gz", hash = "sha256:b1704e0847db01817624a6b86766967f552dd9dbf3afba4004409f908dcc84e6"}, + {file = "pydantic-2.7.4-py3-none-any.whl", hash = "sha256:ee8538d41ccb9c0a9ad3e0e5f07bf15ed8015b481ced539a1759d8cc89ae90d0"}, + {file = "pydantic-2.7.4.tar.gz", hash = "sha256:0c84efd9548d545f63ac0060c1e4d39bb9b14db8b3c0652338aecc07b5adec52"}, ] [package.dependencies] annotated-types = ">=0.4.0" -pydantic-core = "2.16.3" +pydantic-core = "2.18.4" typing-extensions = ">=4.6.1" [package.extras] @@ -255,90 +254,90 @@ email = ["email-validator (>=2.0.0)"] [[package]] name = "pydantic-core" -version = "2.16.3" -description = "" +version = "2.18.4" +description = "Core functionality for Pydantic validation and serialization" optional = false python-versions = ">=3.8" files = [ - {file = "pydantic_core-2.16.3-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:75b81e678d1c1ede0785c7f46690621e4c6e63ccd9192af1f0bd9d504bbb6bf4"}, - {file = "pydantic_core-2.16.3-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:9c865a7ee6f93783bd5d781af5a4c43dadc37053a5b42f7d18dc019f8c9d2bd1"}, - {file = "pydantic_core-2.16.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:162e498303d2b1c036b957a1278fa0899d02b2842f1ff901b6395104c5554a45"}, - {file = "pydantic_core-2.16.3-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:2f583bd01bbfbff4eaee0868e6fc607efdfcc2b03c1c766b06a707abbc856187"}, - {file = "pydantic_core-2.16.3-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:b926dd38db1519ed3043a4de50214e0d600d404099c3392f098a7f9d75029ff8"}, - {file = "pydantic_core-2.16.3-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:716b542728d4c742353448765aa7cdaa519a7b82f9564130e2b3f6766018c9ec"}, - {file = "pydantic_core-2.16.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:fc4ad7f7ee1a13d9cb49d8198cd7d7e3aa93e425f371a68235f784e99741561f"}, - {file = "pydantic_core-2.16.3-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:bd87f48924f360e5d1c5f770d6155ce0e7d83f7b4e10c2f9ec001c73cf475c99"}, - {file = "pydantic_core-2.16.3-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:0df446663464884297c793874573549229f9eca73b59360878f382a0fc085979"}, - {file = "pydantic_core-2.16.3-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:4df8a199d9f6afc5ae9a65f8f95ee52cae389a8c6b20163762bde0426275b7db"}, - {file = "pydantic_core-2.16.3-cp310-none-win32.whl", hash = "sha256:456855f57b413f077dff513a5a28ed838dbbb15082ba00f80750377eed23d132"}, - {file = "pydantic_core-2.16.3-cp310-none-win_amd64.whl", hash = "sha256:732da3243e1b8d3eab8c6ae23ae6a58548849d2e4a4e03a1924c8ddf71a387cb"}, - {file = "pydantic_core-2.16.3-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:519ae0312616026bf4cedc0fe459e982734f3ca82ee8c7246c19b650b60a5ee4"}, - {file = "pydantic_core-2.16.3-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:b3992a322a5617ded0a9f23fd06dbc1e4bd7cf39bc4ccf344b10f80af58beacd"}, - {file = "pydantic_core-2.16.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8d62da299c6ecb04df729e4b5c52dc0d53f4f8430b4492b93aa8de1f541c4aac"}, - {file = "pydantic_core-2.16.3-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:2acca2be4bb2f2147ada8cac612f8a98fc09f41c89f87add7256ad27332c2fda"}, - {file = "pydantic_core-2.16.3-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:1b662180108c55dfbf1280d865b2d116633d436cfc0bba82323554873967b340"}, - {file = "pydantic_core-2.16.3-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e7c6ed0dc9d8e65f24f5824291550139fe6f37fac03788d4580da0d33bc00c97"}, - {file = "pydantic_core-2.16.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a6b1bb0827f56654b4437955555dc3aeeebeddc47c2d7ed575477f082622c49e"}, - {file = "pydantic_core-2.16.3-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:e56f8186d6210ac7ece503193ec84104da7ceb98f68ce18c07282fcc2452e76f"}, - {file = "pydantic_core-2.16.3-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:936e5db01dd49476fa8f4383c259b8b1303d5dd5fb34c97de194560698cc2c5e"}, - {file = "pydantic_core-2.16.3-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:33809aebac276089b78db106ee692bdc9044710e26f24a9a2eaa35a0f9fa70ba"}, - {file = "pydantic_core-2.16.3-cp311-none-win32.whl", hash = "sha256:ded1c35f15c9dea16ead9bffcde9bb5c7c031bff076355dc58dcb1cb436c4721"}, - {file = "pydantic_core-2.16.3-cp311-none-win_amd64.whl", hash = "sha256:d89ca19cdd0dd5f31606a9329e309d4fcbb3df860960acec32630297d61820df"}, - {file = "pydantic_core-2.16.3-cp311-none-win_arm64.whl", hash = "sha256:6162f8d2dc27ba21027f261e4fa26f8bcb3cf9784b7f9499466a311ac284b5b9"}, - {file = "pydantic_core-2.16.3-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:0f56ae86b60ea987ae8bcd6654a887238fd53d1384f9b222ac457070b7ac4cff"}, - {file = "pydantic_core-2.16.3-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:c9bd22a2a639e26171068f8ebb5400ce2c1bc7d17959f60a3b753ae13c632975"}, - {file = "pydantic_core-2.16.3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4204e773b4b408062960e65468d5346bdfe139247ee5f1ca2a378983e11388a2"}, - {file = "pydantic_core-2.16.3-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:f651dd19363c632f4abe3480a7c87a9773be27cfe1341aef06e8759599454120"}, - {file = "pydantic_core-2.16.3-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:aaf09e615a0bf98d406657e0008e4a8701b11481840be7d31755dc9f97c44053"}, - {file = "pydantic_core-2.16.3-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:8e47755d8152c1ab5b55928ab422a76e2e7b22b5ed8e90a7d584268dd49e9c6b"}, - {file = "pydantic_core-2.16.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:500960cb3a0543a724a81ba859da816e8cf01b0e6aaeedf2c3775d12ee49cade"}, - {file = "pydantic_core-2.16.3-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:cf6204fe865da605285c34cf1172879d0314ff267b1c35ff59de7154f35fdc2e"}, - {file = "pydantic_core-2.16.3-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:d33dd21f572545649f90c38c227cc8631268ba25c460b5569abebdd0ec5974ca"}, - {file = "pydantic_core-2.16.3-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:49d5d58abd4b83fb8ce763be7794d09b2f50f10aa65c0f0c1696c677edeb7cbf"}, - {file = "pydantic_core-2.16.3-cp312-none-win32.whl", hash = "sha256:f53aace168a2a10582e570b7736cc5bef12cae9cf21775e3eafac597e8551fbe"}, - {file = "pydantic_core-2.16.3-cp312-none-win_amd64.whl", hash = "sha256:0d32576b1de5a30d9a97f300cc6a3f4694c428d956adbc7e6e2f9cad279e45ed"}, - {file = "pydantic_core-2.16.3-cp312-none-win_arm64.whl", hash = "sha256:ec08be75bb268473677edb83ba71e7e74b43c008e4a7b1907c6d57e940bf34b6"}, - {file = "pydantic_core-2.16.3-cp38-cp38-macosx_10_12_x86_64.whl", hash = "sha256:b1f6f5938d63c6139860f044e2538baeee6f0b251a1816e7adb6cbce106a1f01"}, - {file = "pydantic_core-2.16.3-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:2a1ef6a36fdbf71538142ed604ad19b82f67b05749512e47f247a6ddd06afdc7"}, - {file = "pydantic_core-2.16.3-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:704d35ecc7e9c31d48926150afada60401c55efa3b46cd1ded5a01bdffaf1d48"}, - {file = "pydantic_core-2.16.3-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:d937653a696465677ed583124b94a4b2d79f5e30b2c46115a68e482c6a591c8a"}, - {file = "pydantic_core-2.16.3-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c9803edf8e29bd825f43481f19c37f50d2b01899448273b3a7758441b512acf8"}, - {file = "pydantic_core-2.16.3-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:72282ad4892a9fb2da25defeac8c2e84352c108705c972db82ab121d15f14e6d"}, - {file = "pydantic_core-2.16.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7f752826b5b8361193df55afcdf8ca6a57d0232653494ba473630a83ba50d8c9"}, - {file = "pydantic_core-2.16.3-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:4384a8f68ddb31a0b0c3deae88765f5868a1b9148939c3f4121233314ad5532c"}, - {file = "pydantic_core-2.16.3-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:a4b2bf78342c40b3dc830880106f54328928ff03e357935ad26c7128bbd66ce8"}, - {file = "pydantic_core-2.16.3-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:13dcc4802961b5f843a9385fc821a0b0135e8c07fc3d9949fd49627c1a5e6ae5"}, - {file = "pydantic_core-2.16.3-cp38-none-win32.whl", hash = "sha256:e3e70c94a0c3841e6aa831edab1619ad5c511199be94d0c11ba75fe06efe107a"}, - {file = "pydantic_core-2.16.3-cp38-none-win_amd64.whl", hash = "sha256:ecdf6bf5f578615f2e985a5e1f6572e23aa632c4bd1dc67f8f406d445ac115ed"}, - {file = "pydantic_core-2.16.3-cp39-cp39-macosx_10_12_x86_64.whl", hash = "sha256:bda1ee3e08252b8d41fa5537413ffdddd58fa73107171a126d3b9ff001b9b820"}, - {file = "pydantic_core-2.16.3-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:21b888c973e4f26b7a96491c0965a8a312e13be108022ee510248fe379a5fa23"}, - {file = "pydantic_core-2.16.3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:be0ec334369316fa73448cc8c982c01e5d2a81c95969d58b8f6e272884df0074"}, - {file = "pydantic_core-2.16.3-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:b5b6079cc452a7c53dd378c6f881ac528246b3ac9aae0f8eef98498a75657805"}, - {file = "pydantic_core-2.16.3-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:7ee8d5f878dccb6d499ba4d30d757111847b6849ae07acdd1205fffa1fc1253c"}, - {file = "pydantic_core-2.16.3-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:7233d65d9d651242a68801159763d09e9ec96e8a158dbf118dc090cd77a104c9"}, - {file = "pydantic_core-2.16.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c6119dc90483a5cb50a1306adb8d52c66e447da88ea44f323e0ae1a5fcb14256"}, - {file = "pydantic_core-2.16.3-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:578114bc803a4c1ff9946d977c221e4376620a46cf78da267d946397dc9514a8"}, - {file = "pydantic_core-2.16.3-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:d8f99b147ff3fcf6b3cc60cb0c39ea443884d5559a30b1481e92495f2310ff2b"}, - {file = "pydantic_core-2.16.3-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:4ac6b4ce1e7283d715c4b729d8f9dab9627586dafce81d9eaa009dd7f25dd972"}, - {file = "pydantic_core-2.16.3-cp39-none-win32.whl", hash = "sha256:e7774b570e61cb998490c5235740d475413a1f6de823169b4cf94e2fe9e9f6b2"}, - {file = "pydantic_core-2.16.3-cp39-none-win_amd64.whl", hash = "sha256:9091632a25b8b87b9a605ec0e61f241c456e9248bfdcf7abdf344fdb169c81cf"}, - {file = "pydantic_core-2.16.3-pp310-pypy310_pp73-macosx_10_12_x86_64.whl", hash = "sha256:36fa178aacbc277bc6b62a2c3da95226520da4f4e9e206fdf076484363895d2c"}, - {file = "pydantic_core-2.16.3-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:dcca5d2bf65c6fb591fff92da03f94cd4f315972f97c21975398bd4bd046854a"}, - {file = "pydantic_core-2.16.3-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2a72fb9963cba4cd5793854fd12f4cfee731e86df140f59ff52a49b3552db241"}, - {file = "pydantic_core-2.16.3-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b60cc1a081f80a2105a59385b92d82278b15d80ebb3adb200542ae165cd7d183"}, - {file = "pydantic_core-2.16.3-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:cbcc558401de90a746d02ef330c528f2e668c83350f045833543cd57ecead1ad"}, - {file = "pydantic_core-2.16.3-pp310-pypy310_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:fee427241c2d9fb7192b658190f9f5fd6dfe41e02f3c1489d2ec1e6a5ab1e04a"}, - {file = "pydantic_core-2.16.3-pp310-pypy310_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:f4cb85f693044e0f71f394ff76c98ddc1bc0953e48c061725e540396d5c8a2e1"}, - {file = "pydantic_core-2.16.3-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:b29eeb887aa931c2fcef5aa515d9d176d25006794610c264ddc114c053bf96fe"}, - {file = "pydantic_core-2.16.3-pp39-pypy39_pp73-macosx_10_12_x86_64.whl", hash = "sha256:a425479ee40ff021f8216c9d07a6a3b54b31c8267c6e17aa88b70d7ebd0e5e5b"}, - {file = "pydantic_core-2.16.3-pp39-pypy39_pp73-macosx_11_0_arm64.whl", hash = "sha256:5c5cbc703168d1b7a838668998308018a2718c2130595e8e190220238addc96f"}, - {file = "pydantic_core-2.16.3-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:99b6add4c0b39a513d323d3b93bc173dac663c27b99860dd5bf491b240d26137"}, - {file = "pydantic_core-2.16.3-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:75f76ee558751746d6a38f89d60b6228fa174e5172d143886af0f85aa306fd89"}, - {file = "pydantic_core-2.16.3-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:00ee1c97b5364b84cb0bd82e9bbf645d5e2871fb8c58059d158412fee2d33d8a"}, - {file = "pydantic_core-2.16.3-pp39-pypy39_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:287073c66748f624be4cef893ef9174e3eb88fe0b8a78dc22e88eca4bc357ca6"}, - {file = "pydantic_core-2.16.3-pp39-pypy39_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:ed25e1835c00a332cb10c683cd39da96a719ab1dfc08427d476bce41b92531fc"}, - {file = "pydantic_core-2.16.3-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:86b3d0033580bd6bbe07590152007275bd7af95f98eaa5bd36f3da219dcd93da"}, - {file = "pydantic_core-2.16.3.tar.gz", hash = "sha256:1cac689f80a3abab2d3c0048b29eea5751114054f032a941a32de4c852c59cad"}, + {file = "pydantic_core-2.18.4-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:f76d0ad001edd426b92233d45c746fd08f467d56100fd8f30e9ace4b005266e4"}, + {file = "pydantic_core-2.18.4-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:59ff3e89f4eaf14050c8022011862df275b552caef8082e37b542b066ce1ff26"}, + {file = "pydantic_core-2.18.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a55b5b16c839df1070bc113c1f7f94a0af4433fcfa1b41799ce7606e5c79ce0a"}, + {file = "pydantic_core-2.18.4-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:4d0dcc59664fcb8974b356fe0a18a672d6d7cf9f54746c05f43275fc48636851"}, + {file = "pydantic_core-2.18.4-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:8951eee36c57cd128f779e641e21eb40bc5073eb28b2d23f33eb0ef14ffb3f5d"}, + {file = "pydantic_core-2.18.4-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:4701b19f7e3a06ea655513f7938de6f108123bf7c86bbebb1196eb9bd35cf724"}, + {file = "pydantic_core-2.18.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e00a3f196329e08e43d99b79b286d60ce46bed10f2280d25a1718399457e06be"}, + {file = "pydantic_core-2.18.4-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:97736815b9cc893b2b7f663628e63f436018b75f44854c8027040e05230eeddb"}, + {file = "pydantic_core-2.18.4-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:6891a2ae0e8692679c07728819b6e2b822fb30ca7445f67bbf6509b25a96332c"}, + {file = "pydantic_core-2.18.4-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:bc4ff9805858bd54d1a20efff925ccd89c9d2e7cf4986144b30802bf78091c3e"}, + {file = "pydantic_core-2.18.4-cp310-none-win32.whl", hash = "sha256:1b4de2e51bbcb61fdebd0ab86ef28062704f62c82bbf4addc4e37fa4b00b7cbc"}, + {file = "pydantic_core-2.18.4-cp310-none-win_amd64.whl", hash = "sha256:6a750aec7bf431517a9fd78cb93c97b9b0c496090fee84a47a0d23668976b4b0"}, + {file = "pydantic_core-2.18.4-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:942ba11e7dfb66dc70f9ae66b33452f51ac7bb90676da39a7345e99ffb55402d"}, + {file = "pydantic_core-2.18.4-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:b2ebef0e0b4454320274f5e83a41844c63438fdc874ea40a8b5b4ecb7693f1c4"}, + {file = "pydantic_core-2.18.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a642295cd0c8df1b86fc3dced1d067874c353a188dc8e0f744626d49e9aa51c4"}, + {file = "pydantic_core-2.18.4-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:5f09baa656c904807e832cf9cce799c6460c450c4ad80803517032da0cd062e2"}, + {file = "pydantic_core-2.18.4-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:98906207f29bc2c459ff64fa007afd10a8c8ac080f7e4d5beff4c97086a3dabd"}, + {file = "pydantic_core-2.18.4-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:19894b95aacfa98e7cb093cd7881a0c76f55731efad31073db4521e2b6ff5b7d"}, + {file = "pydantic_core-2.18.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0fbbdc827fe5e42e4d196c746b890b3d72876bdbf160b0eafe9f0334525119c8"}, + {file = "pydantic_core-2.18.4-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:f85d05aa0918283cf29a30b547b4df2fbb56b45b135f9e35b6807cb28bc47951"}, + {file = "pydantic_core-2.18.4-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:e85637bc8fe81ddb73fda9e56bab24560bdddfa98aa64f87aaa4e4b6730c23d2"}, + {file = "pydantic_core-2.18.4-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:2f5966897e5461f818e136b8451d0551a2e77259eb0f73a837027b47dc95dab9"}, + {file = "pydantic_core-2.18.4-cp311-none-win32.whl", hash = "sha256:44c7486a4228413c317952e9d89598bcdfb06399735e49e0f8df643e1ccd0558"}, + {file = "pydantic_core-2.18.4-cp311-none-win_amd64.whl", hash = "sha256:8a7164fe2005d03c64fd3b85649891cd4953a8de53107940bf272500ba8a788b"}, + {file = "pydantic_core-2.18.4-cp311-none-win_arm64.whl", hash = "sha256:4e99bc050fe65c450344421017f98298a97cefc18c53bb2f7b3531eb39bc7805"}, + {file = "pydantic_core-2.18.4-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:6f5c4d41b2771c730ea1c34e458e781b18cc668d194958e0112455fff4e402b2"}, + {file = "pydantic_core-2.18.4-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:2fdf2156aa3d017fddf8aea5adfba9f777db1d6022d392b682d2a8329e087cef"}, + {file = "pydantic_core-2.18.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4748321b5078216070b151d5271ef3e7cc905ab170bbfd27d5c83ee3ec436695"}, + {file = "pydantic_core-2.18.4-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:847a35c4d58721c5dc3dba599878ebbdfd96784f3fb8bb2c356e123bdcd73f34"}, + {file = "pydantic_core-2.18.4-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3c40d4eaad41f78e3bbda31b89edc46a3f3dc6e171bf0ecf097ff7a0ffff7cb1"}, + {file = "pydantic_core-2.18.4-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:21a5e440dbe315ab9825fcd459b8814bb92b27c974cbc23c3e8baa2b76890077"}, + {file = "pydantic_core-2.18.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:01dd777215e2aa86dfd664daed5957704b769e726626393438f9c87690ce78c3"}, + {file = "pydantic_core-2.18.4-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:4b06beb3b3f1479d32befd1f3079cc47b34fa2da62457cdf6c963393340b56e9"}, + {file = "pydantic_core-2.18.4-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:564d7922e4b13a16b98772441879fcdcbe82ff50daa622d681dd682175ea918c"}, + {file = "pydantic_core-2.18.4-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:0eb2a4f660fcd8e2b1c90ad566db2b98d7f3f4717c64fe0a83e0adb39766d5b8"}, + {file = "pydantic_core-2.18.4-cp312-none-win32.whl", hash = "sha256:8b8bab4c97248095ae0c4455b5a1cd1cdd96e4e4769306ab19dda135ea4cdb07"}, + {file = "pydantic_core-2.18.4-cp312-none-win_amd64.whl", hash = "sha256:14601cdb733d741b8958224030e2bfe21a4a881fb3dd6fbb21f071cabd48fa0a"}, + {file = "pydantic_core-2.18.4-cp312-none-win_arm64.whl", hash = "sha256:c1322d7dd74713dcc157a2b7898a564ab091ca6c58302d5c7b4c07296e3fd00f"}, + {file = "pydantic_core-2.18.4-cp38-cp38-macosx_10_12_x86_64.whl", hash = "sha256:823be1deb01793da05ecb0484d6c9e20baebb39bd42b5d72636ae9cf8350dbd2"}, + {file = "pydantic_core-2.18.4-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:ebef0dd9bf9b812bf75bda96743f2a6c5734a02092ae7f721c048d156d5fabae"}, + {file = "pydantic_core-2.18.4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ae1d6df168efb88d7d522664693607b80b4080be6750c913eefb77e34c12c71a"}, + {file = "pydantic_core-2.18.4-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:f9899c94762343f2cc2fc64c13e7cae4c3cc65cdfc87dd810a31654c9b7358cc"}, + {file = "pydantic_core-2.18.4-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:99457f184ad90235cfe8461c4d70ab7dd2680e28821c29eca00252ba90308c78"}, + {file = "pydantic_core-2.18.4-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:18f469a3d2a2fdafe99296a87e8a4c37748b5080a26b806a707f25a902c040a8"}, + {file = "pydantic_core-2.18.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b7cdf28938ac6b8b49ae5e92f2735056a7ba99c9b110a474473fd71185c1af5d"}, + {file = "pydantic_core-2.18.4-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:938cb21650855054dc54dfd9120a851c974f95450f00683399006aa6e8abb057"}, + {file = "pydantic_core-2.18.4-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:44cd83ab6a51da80fb5adbd9560e26018e2ac7826f9626bc06ca3dc074cd198b"}, + {file = "pydantic_core-2.18.4-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:972658f4a72d02b8abfa2581d92d59f59897d2e9f7e708fdabe922f9087773af"}, + {file = "pydantic_core-2.18.4-cp38-none-win32.whl", hash = "sha256:1d886dc848e60cb7666f771e406acae54ab279b9f1e4143babc9c2258213daa2"}, + {file = "pydantic_core-2.18.4-cp38-none-win_amd64.whl", hash = "sha256:bb4462bd43c2460774914b8525f79b00f8f407c945d50881568f294c1d9b4443"}, + {file = "pydantic_core-2.18.4-cp39-cp39-macosx_10_12_x86_64.whl", hash = "sha256:44a688331d4a4e2129140a8118479443bd6f1905231138971372fcde37e43528"}, + {file = "pydantic_core-2.18.4-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:a2fdd81edd64342c85ac7cf2753ccae0b79bf2dfa063785503cb85a7d3593223"}, + {file = "pydantic_core-2.18.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:86110d7e1907ab36691f80b33eb2da87d780f4739ae773e5fc83fb272f88825f"}, + {file = "pydantic_core-2.18.4-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:46387e38bd641b3ee5ce247563b60c5ca098da9c56c75c157a05eaa0933ed154"}, + {file = "pydantic_core-2.18.4-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:123c3cec203e3f5ac7b000bd82235f1a3eced8665b63d18be751f115588fea30"}, + {file = "pydantic_core-2.18.4-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:dc1803ac5c32ec324c5261c7209e8f8ce88e83254c4e1aebdc8b0a39f9ddb443"}, + {file = "pydantic_core-2.18.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:53db086f9f6ab2b4061958d9c276d1dbe3690e8dd727d6abf2321d6cce37fa94"}, + {file = "pydantic_core-2.18.4-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:abc267fa9837245cc28ea6929f19fa335f3dc330a35d2e45509b6566dc18be23"}, + {file = "pydantic_core-2.18.4-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:a0d829524aaefdebccb869eed855e2d04c21d2d7479b6cada7ace5448416597b"}, + {file = "pydantic_core-2.18.4-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:509daade3b8649f80d4e5ff21aa5673e4ebe58590b25fe42fac5f0f52c6f034a"}, + {file = "pydantic_core-2.18.4-cp39-none-win32.whl", hash = "sha256:ca26a1e73c48cfc54c4a76ff78df3727b9d9f4ccc8dbee4ae3f73306a591676d"}, + {file = "pydantic_core-2.18.4-cp39-none-win_amd64.whl", hash = "sha256:c67598100338d5d985db1b3d21f3619ef392e185e71b8d52bceacc4a7771ea7e"}, + {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-macosx_10_12_x86_64.whl", hash = "sha256:574d92eac874f7f4db0ca653514d823a0d22e2354359d0759e3f6a406db5d55d"}, + {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:1f4d26ceb5eb9eed4af91bebeae4b06c3fb28966ca3a8fb765208cf6b51102ab"}, + {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:77450e6d20016ec41f43ca4a6c63e9fdde03f0ae3fe90e7c27bdbeaece8b1ed4"}, + {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d323a01da91851a4f17bf592faf46149c9169d68430b3146dcba2bb5e5719abc"}, + {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:43d447dd2ae072a0065389092a231283f62d960030ecd27565672bd40746c507"}, + {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:578e24f761f3b425834f297b9935e1ce2e30f51400964ce4801002435a1b41ef"}, + {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:81b5efb2f126454586d0f40c4d834010979cb80785173d1586df845a632e4e6d"}, + {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:ab86ce7c8f9bea87b9d12c7f0af71102acbf5ecbc66c17796cff45dae54ef9a5"}, + {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-macosx_10_12_x86_64.whl", hash = "sha256:90afc12421df2b1b4dcc975f814e21bc1754640d502a2fbcc6d41e77af5ec312"}, + {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-macosx_11_0_arm64.whl", hash = "sha256:51991a89639a912c17bef4b45c87bd83593aee0437d8102556af4885811d59f5"}, + {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:293afe532740370aba8c060882f7d26cfd00c94cae32fd2e212a3a6e3b7bc15e"}, + {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b48ece5bde2e768197a2d0f6e925f9d7e3e826f0ad2271120f8144a9db18d5c8"}, + {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:eae237477a873ab46e8dd748e515c72c0c804fb380fbe6c85533c7de51f23a8f"}, + {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:834b5230b5dfc0c1ec37b2fda433b271cbbc0e507560b5d1588e2cc1148cf1ce"}, + {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:e858ac0a25074ba4bce653f9b5d0a85b7456eaddadc0ce82d3878c22489fa4ee"}, + {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:2fd41f6eff4c20778d717af1cc50eca52f5afe7805ee530a4fbd0bae284f16e9"}, + {file = "pydantic_core-2.18.4.tar.gz", hash = "sha256:ec3beeada09ff865c344ff3bc2f427f5e6c26401cc6113d77e372c3fdac73864"}, ] [package.dependencies] @@ -366,6 +365,49 @@ tomli = {version = ">=1.0.0", markers = "python_version < \"3.11\""} [package.extras] testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"] +[[package]] +name = "pytest-asyncio" +version = "0.23.7" +description = "Pytest support for asyncio" +optional = false +python-versions = ">=3.8" +files = [ + {file = "pytest_asyncio-0.23.7-py3-none-any.whl", hash = "sha256:009b48127fbe44518a547bddd25611551b0e43ccdbf1e67d12479f569832c20b"}, + {file = "pytest_asyncio-0.23.7.tar.gz", hash = "sha256:5f5c72948f4c49e7db4f29f2521d4031f1c27f86e57b046126654083d4770268"}, +] + +[package.dependencies] +pytest = ">=7.0.0,<9" + +[package.extras] +docs = ["sphinx (>=5.3)", "sphinx-rtd-theme (>=1.0)"] +testing = ["coverage (>=6.2)", "hypothesis (>=5.7.1)"] + +[[package]] +name = "python-dateutil" +version = "2.9.0.post0" +description = "Extensions to the standard Python datetime module" +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" +files = [ + {file = "python-dateutil-2.9.0.post0.tar.gz", hash = "sha256:37dd54208da7e1cd875388217d5e00ebd4179249f90fb72437e91a35459a0ad3"}, + {file = "python_dateutil-2.9.0.post0-py2.py3-none-any.whl", hash = "sha256:a8b2bc7bffae282281c8140a97d3aa9c14da0b136dfe83f850eea9a5f7470427"}, +] + +[package.dependencies] +six = ">=1.5" + +[[package]] +name = "six" +version = "1.16.0" +description = "Python 2 and 3 compatibility utilities" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" +files = [ + {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, + {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, +] + [[package]] name = "sniffio" version = "1.3.1" @@ -388,18 +430,29 @@ files = [ {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, ] +[[package]] +name = "types-python-dateutil" +version = "2.9.0.20240316" +description = "Typing stubs for python-dateutil" +optional = false +python-versions = ">=3.8" +files = [ + {file = "types-python-dateutil-2.9.0.20240316.tar.gz", hash = "sha256:5d2f2e240b86905e40944dd787db6da9263f0deabef1076ddaed797351ec0202"}, + {file = "types_python_dateutil-2.9.0.20240316-py3-none-any.whl", hash = "sha256:6b8cb66d960771ce5ff974e9dd45e38facb81718cc1e208b10b1baccbfdbee3b"}, +] + [[package]] name = "typing-extensions" -version = "4.10.0" +version = "4.12.2" description = "Backported and Experimental Type Hints for Python 3.8+" optional = false python-versions = ">=3.8" files = [ - {file = "typing_extensions-4.10.0-py3-none-any.whl", hash = "sha256:69b1a937c3a517342112fb4c6df7e72fc39a38e7891a5730ed4985b5214b5475"}, - {file = "typing_extensions-4.10.0.tar.gz", hash = "sha256:b0abd7c89e8fb96f98db18d86106ff1d90ab692004eb746cf6eda2682f91b3cb"}, + {file = "typing_extensions-4.12.2-py3-none-any.whl", hash = "sha256:04e5ca0351e0f3f85c6853954072df659d0d13fac324d0072316b67d7794700d"}, + {file = "typing_extensions-4.12.2.tar.gz", hash = "sha256:1a7ead55c7e559dd4dee8856e3a88b41225abfe1ce8df57b7c13915fe121ffb8"}, ] [metadata] lock-version = "2.0" python-versions = "^3.8" -content-hash = "3c8fae8de68e5484c48073bf191e51acbe3b9a32fd98e6b5e4d165e42a7fc7aa" +content-hash = "7fa2085bd251148908cf9a89f13b158fe85ccb037bb44614ae5f150ceecee53c" diff --git a/pyproject.toml b/pyproject.toml index 2ade12a..ca24275 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,13 +1,35 @@ [tool.poetry] name = "webflow" -version = "v1.2.0" +version = "1.2.2" description = "" readme = "README.md" authors = [] +keywords = [] + +classifiers = [ + "Intended Audience :: Developers", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Operating System :: OS Independent", + "Operating System :: POSIX", + "Operating System :: MacOS", + "Operating System :: POSIX :: Linux", + "Operating System :: Microsoft :: Windows", + "Topic :: Software Development :: Libraries :: Python Modules", + "Typing :: Typed" +] packages = [ { include = "webflow", from = "src"} ] +[project.urls] +Repository = 'https://github.com/webflow/webflow-python' + [tool.poetry.dependencies] python = "^3.8" httpx = ">=0.21.2" @@ -15,8 +37,19 @@ pydantic = ">= 1.9.2" typing_extensions = ">= 4.0.0" [tool.poetry.dev-dependencies] -mypy = "^1.8.0" +mypy = "1.0.1" pytest = "^7.4.0" +pytest-asyncio = "^0.23.5" +python-dateutil = "^2.9.0" +types-python-dateutil = "^2.9.0.20240316" + +[tool.pytest.ini_options] +testpaths = [ "tests" ] +asyncio_mode = "auto" + +[tool.mypy] +plugins = ["pydantic.mypy"] + [build-system] requires = ["poetry-core"] diff --git a/reference.md b/reference.md new file mode 100644 index 0000000..5110fae --- /dev/null +++ b/reference.md @@ -0,0 +1,7234 @@ +# Reference +## Token +
client.token.authorized_by() +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Information about the Authorized User

Required Scope | `authorized_user:read` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.token.authorized_by() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.token.introspect() +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Information about the authorization token
Access to this endpoint requires a bearer token from a Data Client App.
+
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.token.introspect() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Sites +
client.sites.list() +
+
+ +#### 📝 Description + +
+
+ +
+
+ +List of all sites the provided access token is able to access.

Required scope | `sites:read` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.sites.list() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.sites.get(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get a site by site id

Required scope | `sites:read` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.sites.get( + site_id="site_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**site_id:** `str` — Unique identifier for a Site + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.sites.get_custom_domain(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get a list of all custom domains related to site.

Required scope | `sites:read` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.sites.get_custom_domain( + site_id="site_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**site_id:** `str` — Unique identifier for a Site + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.sites.publish(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Publish a site to one more more domains.

Required scope | `sites:write` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.sites.publish( + site_id="site_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**site_id:** `str` — Unique identifier for a Site + +
+
+ +
+
+ +**custom_domains:** `typing.Optional[typing.Sequence[str]]` — Array of Custom Domain ids to publish + +
+
+ +
+
+ +**publish_to_webflow_subdomain:** `typing.Optional[bool]` — Choice of whether to publish to the default Webflow Subdomain + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Sites ActivityLogs +
client.sites.activity_logs.list(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve Activity Logs for a specific Site. Requires Site to be on an Enterprise plan.

Required scope | `site_activity:read` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.sites.activity_logs.list( + site_id="site_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**site_id:** `str` — Unique identifier for a Site + +
+
+ +
+
+ +**limit:** `typing.Optional[float]` — Maximum number of records to be returned (max limit: 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[float]` — Offset used for pagination if the results have more than limit records + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Collections +
client.collections.list(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +List of all Collections within a Site.

Required scope | `cms:read` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.collections.list( + site_id="site_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**site_id:** `str` — Unique identifier for a Site + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.collections.create(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create a Collection for a site.

Required scope | `cms:write` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.collections.create( + site_id="site_id", + display_name="Blog Posts", + singular_name="Blog Post", + slug="posts", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**site_id:** `str` — Unique identifier for a Site + +
+
+ +
+
+ +**display_name:** `str` — Name of the collection. Each collection name must be distinct. + +
+
+ +
+
+ +**singular_name:** `str` — Singular name of each item. + +
+
+ +
+
+ +**slug:** `typing.Optional[str]` — Part of a URL that identifier + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.collections.get(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get the full details of a collection from its ID.

Required scope | `cms:read` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.collections.get( + collection_id="collection_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**collection_id:** `str` — Unique identifier for a Collection + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.collections.delete_collection(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete a collection using its ID.

Required scope | `cms:write` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.collections.delete_collection( + collection_id="collection_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**collection_id:** `str` — Unique identifier for a Collection + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.collections.delete(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete a custom field in a collection. This endpoint does not currently support bulk deletion.

Required scope | `cms:write` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.collections.delete( + collection_id="collection_id", + field_id="field_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**collection_id:** `str` — Unique identifier for a Collection + +
+
+ +
+
+ +**field_id:** `str` — Unique identifier for a Field in a collection + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Collections Fields +
client.collections.fields.create(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create a custom field in a collection.

Slugs must be all lowercase letters without spaces. If you pass a string with uppercase letters and/or spaces to the "Slug" property, Webflow will convert the slug to lowercase and replace spaces with "-."

Only some field types can be created through the API. This endpoint does not currently support bulk creation.

Required scope | `cms:write` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow +from webflow.resources.collections import FieldCreateType + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.collections.fields.create( + collection_id="collection_id", + is_required=False, + type=FieldCreateType.RICH_TEXT, + display_name="Post Body", + help_text="Add the body of your post here", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**collection_id:** `str` — Unique identifier for a Collection + +
+
+ +
+
+ +**type:** `FieldCreateType` — Choose these appropriate field type for your collection data + +
+
+ +
+
+ +**display_name:** `str` — The name of a field + +
+
+ +
+
+ +**is_required:** `typing.Optional[bool]` — define whether a field is required in a collection + +
+
+ +
+
+ +**help_text:** `typing.Optional[str]` — Additional text to help anyone filling out this field + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.collections.fields.update(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Update a custom field in a collection.

Required scope | `cms:write` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.collections.fields.update( + collection_id="collection_id", + field_id="field_id", + is_required=False, + display_name="Post Body", + help_text="Add the body of your post here", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**collection_id:** `str` — Unique identifier for a Collection + +
+
+ +
+
+ +**field_id:** `str` — Unique identifier for a Field in a collection + +
+
+ +
+
+ +**is_required:** `typing.Optional[bool]` — Define whether a field is required in a collection + +
+
+ +
+
+ +**display_name:** `typing.Optional[str]` — The name of a field + +
+
+ +
+
+ +**help_text:** `typing.Optional[str]` — Additional text to help anyone filling out this field + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Collections Items +
client.collections.items.list_items(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +List of all Items within a Collection.

Required scope | `CMS:read` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.collections.items.list_items( + collection_id="collection_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**collection_id:** `str` — Unique identifier for a Collection + +
+
+ +
+
+ +**cms_locale_id:** `typing.Optional[str]` — Unique identifier for a CMS Locale. This UID is different from the Site locale identifier and is listed as `cmsLocaleId` in the Sites response. To query multiple locales, input a comma separated string. + +
+
+ +
+
+ +**offset:** `typing.Optional[float]` — Offset used for pagination if the results have more than limit records + +
+
+ +
+
+ +**limit:** `typing.Optional[float]` — Maximum number of records to be returned (max limit: 100) + +
+
+ +
+
+ +**name:** `typing.Optional[str]` — The name of the item(s) + +
+
+ +
+
+ +**slug:** `typing.Optional[str]` — The slug of the item + +
+
+ +
+
+ +**sort_by:** `typing.Optional[ItemsListItemsRequestSortBy]` — Sort results by the provided value + +
+
+ +
+
+ +**sort_order:** `typing.Optional[ItemsListItemsRequestSortOrder]` — Sorts the results by asc or desc + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.collections.items.create_item(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create Item in a Collection.

To create items across multiple locales, please use this endpoint.

Required scope | `CMS:write` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow import CollectionItemFieldData +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.collections.items.create_item( + collection_id="collection_id", + id="42b720ef280c7a7a3be8cabe", + cms_locale_id="653ad57de882f528b32e810e", + last_published="2022-11-29T16:22:43.159Z", + last_updated="2022-11-17T17:19:43.282Z", + created_on="2022-11-17T17:11:57.148Z", + is_archived=False, + is_draft=False, + field_data=CollectionItemFieldData( + name="Pan Galactic Gargle Blaster Recipe", + slug="pan-galactic-gargle-blaster", + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**collection_id:** `str` — Unique identifier for a Collection + +
+
+ +
+
+ +**id:** `str` — Unique identifier for the Item + +
+
+ +
+
+ +**cms_locale_id:** `typing.Optional[str]` — Identifier for the locale of the CMS item + +
+
+ +
+
+ +**last_published:** `typing.Optional[str]` — The date the item was last published + +
+
+ +
+
+ +**last_updated:** `typing.Optional[str]` — The date the item was last updated + +
+
+ +
+
+ +**created_on:** `typing.Optional[str]` — The date the item was created + +
+
+ +
+
+ +**is_archived:** `typing.Optional[bool]` — Boolean determining if the Item is set to archived + +
+
+ +
+
+ +**is_draft:** `typing.Optional[bool]` — Boolean determining if the Item is set to draft + +
+
+ +
+
+ +**field_data:** `typing.Optional[CollectionItemFieldData]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.collections.items.list_items_live(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +List of all live Items within a Collection.

Required scope | `CMS:read` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.collections.items.list_items_live( + collection_id="collection_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**collection_id:** `str` — Unique identifier for a Collection + +
+
+ +
+
+ +**cms_locale_id:** `typing.Optional[str]` — Unique identifier for a CMS Locale. This UID is different from the Site locale identifier and is listed as `cmsLocaleId` in the Sites response. To query multiple locales, input a comma separated string. + +
+
+ +
+
+ +**offset:** `typing.Optional[float]` — Offset used for pagination if the results have more than limit records + +
+
+ +
+
+ +**limit:** `typing.Optional[float]` — Maximum number of records to be returned (max limit: 100) + +
+
+ +
+
+ +**name:** `typing.Optional[str]` — The name of the item(s) + +
+
+ +
+
+ +**slug:** `typing.Optional[str]` — The slug of the item + +
+
+ +
+
+ +**sort_by:** `typing.Optional[ItemsListItemsLiveRequestSortBy]` — Sort results by the provided value + +
+
+ +
+
+ +**sort_order:** `typing.Optional[ItemsListItemsLiveRequestSortOrder]` — Sorts the results by asc or desc + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.collections.items.create_item_live(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create live Item in a Collection. This Item will be published to the live site.

To create items across multiple locales, please use this endpoint.

Required scope | `CMS:write` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow import CollectionItemFieldData +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.collections.items.create_item_live( + collection_id="collection_id", + id="42b720ef280c7a7a3be8cabe", + cms_locale_id="653ad57de882f528b32e810e", + last_published="2022-11-29T16:22:43.159Z", + last_updated="2022-11-17T17:19:43.282Z", + created_on="2022-11-17T17:11:57.148Z", + is_archived=False, + is_draft=False, + field_data=CollectionItemFieldData( + name="Pan Galactic Gargle Blaster Recipe", + slug="pan-galactic-gargle-blaster", + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**collection_id:** `str` — Unique identifier for a Collection + +
+
+ +
+
+ +**id:** `str` — Unique identifier for the Item + +
+
+ +
+
+ +**cms_locale_id:** `typing.Optional[str]` — Identifier for the locale of the CMS item + +
+
+ +
+
+ +**last_published:** `typing.Optional[str]` — The date the item was last published + +
+
+ +
+
+ +**last_updated:** `typing.Optional[str]` — The date the item was last updated + +
+
+ +
+
+ +**created_on:** `typing.Optional[str]` — The date the item was created + +
+
+ +
+
+ +**is_archived:** `typing.Optional[bool]` — Boolean determining if the Item is set to archived + +
+
+ +
+
+ +**is_draft:** `typing.Optional[bool]` — Boolean determining if the Item is set to draft + +
+
+ +
+
+ +**field_data:** `typing.Optional[CollectionItemFieldData]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.collections.items.create_item_for_multiple_locales(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create single Item in a Collection with multiple corresponding locales.

Required scope | `CMS:write` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.collections.items.create_item_for_multiple_locales( + collection_id="collection_id", + id="580e64008c9a982ac9b8b754", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**collection_id:** `str` — Unique identifier for a Collection + +
+
+ +
+
+ +**id:** `str` — Unique identifier for the Item + +
+
+ +
+
+ +**cms_locale_ids:** `typing.Optional[typing.Sequence[str]]` — Array of identifiers for the locales where the item will be created + +
+
+ +
+
+ +**last_published:** `typing.Optional[str]` — The date the item was last published + +
+
+ +
+
+ +**last_updated:** `typing.Optional[str]` — The date the item was last updated + +
+
+ +
+
+ +**created_on:** `typing.Optional[str]` — The date the item was created + +
+
+ +
+
+ +**is_archived:** `typing.Optional[bool]` — Boolean determining if the Item is set to archived + +
+
+ +
+
+ +**is_draft:** `typing.Optional[bool]` — Boolean determining if the Item is set to draft + +
+
+ +
+
+ +**field_data:** `typing.Optional[BulkCollectionItemFieldData]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.collections.items.get_item(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get details of a selected Collection Item.

Required scope | `CMS:read` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.collections.items.get_item( + collection_id="collection_id", + item_id="item_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**collection_id:** `str` — Unique identifier for a Collection + +
+
+ +
+
+ +**item_id:** `str` — Unique identifier for an Item + +
+
+ +
+
+ +**cms_locale_id:** `typing.Optional[str]` — Unique identifier for a CMS Locale. This UID is different from the Site locale identifier and is listed as `cmsLocaleId` in the Sites response. To query multiple locales, input a comma separated string. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.collections.items.delete_item(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete an Item from a Collection. This endpoint does not currently support bulk deletion.

Required scope | `CMS:write` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.collections.items.delete_item( + collection_id="collection_id", + item_id="item_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**collection_id:** `str` — Unique identifier for a Collection + +
+
+ +
+
+ +**item_id:** `str` — Unique identifier for an Item + +
+
+ +
+
+ +**cms_locale_id:** `typing.Optional[str]` — Unique identifier for a CMS Locale. This UID is different from the Site locale identifier and is listed as `cmsLocaleId` in the Sites response. To query multiple locales, input a comma separated string. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.collections.items.update_item(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Update a selected Item in a Collection.

Required scope | `CMS:write` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow import CollectionItemFieldData +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.collections.items.update_item( + collection_id="collection_id", + item_id="item_id", + id="42b720ef280c7a7a3be8cabe", + cms_locale_id="653ad57de882f528b32e810e", + last_published="2022-11-29T16:22:43.159Z", + last_updated="2022-11-17T17:19:43.282Z", + created_on="2022-11-17T17:11:57.148Z", + is_archived=False, + is_draft=False, + field_data=CollectionItemFieldData( + name="Pan Galactic Gargle Blaster Recipe", + slug="pan-galactic-gargle-blaster", + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**collection_id:** `str` — Unique identifier for a Collection + +
+
+ +
+
+ +**item_id:** `str` — Unique identifier for an Item + +
+
+ +
+
+ +**id:** `str` — Unique identifier for the Item + +
+
+ +
+
+ +**cms_locale_id:** `typing.Optional[str]` — Identifier for the locale of the CMS item + +
+
+ +
+
+ +**last_published:** `typing.Optional[str]` — The date the item was last published + +
+
+ +
+
+ +**last_updated:** `typing.Optional[str]` — The date the item was last updated + +
+
+ +
+
+ +**created_on:** `typing.Optional[str]` — The date the item was created + +
+
+ +
+
+ +**is_archived:** `typing.Optional[bool]` — Boolean determining if the Item is set to archived + +
+
+ +
+
+ +**is_draft:** `typing.Optional[bool]` — Boolean determining if the Item is set to draft + +
+
+ +
+
+ +**field_data:** `typing.Optional[CollectionItemFieldData]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.collections.items.get_item_live(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get details of a selected Collection live Item.

Required scope | `CMS:read` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.collections.items.get_item_live( + collection_id="collection_id", + item_id="item_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**collection_id:** `str` — Unique identifier for a Collection + +
+
+ +
+
+ +**item_id:** `str` — Unique identifier for an Item + +
+
+ +
+
+ +**cms_locale_id:** `typing.Optional[str]` — Unique identifier for a CMS Locale. This UID is different from the Site locale identifier and is listed as `cmsLocaleId` in the Sites response. To query multiple locales, input a comma separated string. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.collections.items.delete_item_live(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Remove a live item from the site. Removing a published item will unpublish the item from the live site and set it to draft. This endpoint does not currently support bulk deletion.

Required scope | `CMS:write` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.collections.items.delete_item_live( + collection_id="collection_id", + item_id="item_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**collection_id:** `str` — Unique identifier for a Collection + +
+
+ +
+
+ +**item_id:** `str` — Unique identifier for an Item + +
+
+ +
+
+ +**cms_locale_id:** `typing.Optional[str]` — Unique identifier for a CMS Locale. This UID is different from the Site locale identifier and is listed as `cmsLocaleId` in the Sites response. To query multiple locales, input a comma separated string. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.collections.items.update_item_live(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Update a selected live Item in a Collection. The updates for this Item will be published to the live site.

Required scope | `CMS:write` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow import CollectionItemFieldData +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.collections.items.update_item_live( + collection_id="collection_id", + item_id="item_id", + id="42b720ef280c7a7a3be8cabe", + cms_locale_id="653ad57de882f528b32e810e", + last_published="2022-11-29T16:22:43.159Z", + last_updated="2022-11-17T17:19:43.282Z", + created_on="2022-11-17T17:11:57.148Z", + is_archived=False, + is_draft=False, + field_data=CollectionItemFieldData( + name="Pan Galactic Gargle Blaster Recipe", + slug="pan-galactic-gargle-blaster", + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**collection_id:** `str` — Unique identifier for a Collection + +
+
+ +
+
+ +**item_id:** `str` — Unique identifier for an Item + +
+
+ +
+
+ +**id:** `str` — Unique identifier for the Item + +
+
+ +
+
+ +**cms_locale_id:** `typing.Optional[str]` — Identifier for the locale of the CMS item + +
+
+ +
+
+ +**last_published:** `typing.Optional[str]` — The date the item was last published + +
+
+ +
+
+ +**last_updated:** `typing.Optional[str]` — The date the item was last updated + +
+
+ +
+
+ +**created_on:** `typing.Optional[str]` — The date the item was created + +
+
+ +
+
+ +**is_archived:** `typing.Optional[bool]` — Boolean determining if the Item is set to archived + +
+
+ +
+
+ +**is_draft:** `typing.Optional[bool]` — Boolean determining if the Item is set to draft + +
+
+ +
+
+ +**field_data:** `typing.Optional[CollectionItemFieldData]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.collections.items.publish_item(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Publish an item or multiple items.

Required scope | `cms:write` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.collections.items.publish_item( + collection_id="collection_id", + item_ids=["itemIds"], +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**collection_id:** `str` — Unique identifier for a Collection + +
+
+ +
+
+ +**item_ids:** `typing.Sequence[str]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Pages +
client.pages.list(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +List of all pages for a site

Required scope | `pages:read` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.pages.list( + site_id="site_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**site_id:** `str` — Unique identifier for a Site + +
+
+ +
+
+ +**locale:** `typing.Optional[str]` — Unique identifier for a specific locale. Applicable, when using localization. + +
+
+ +
+
+ +**limit:** `typing.Optional[float]` — Maximum number of records to be returned (max limit: 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[float]` — Offset used for pagination if the results have more than limit records + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.pages.get_metadata(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get metadata information for a single page

Required scope | `pages:read` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.pages.get_metadata( + page_id="page_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**page_id:** `str` — Unique identifier for a Page + +
+
+ +
+
+ +**locale:** `typing.Optional[str]` — Unique identifier for a specific locale. Applicable, when using localization. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.pages.update_page_settings(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Update Page-level metadata, including SEO and Open Graph fields.

Required scope | `pages:write` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +import datetime + +from webflow import PageOpenGraph, PageSeo +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.pages.update_page_settings( + page_id="page_id", + id="6596da6045e56dee495bcbba", + site_id="6258612d1ee792848f805dcf", + title="Guide to the Galaxy", + slug="guide-to-the-galaxy", + parent_id="6419db964a9c435aa3af6251", + collection_id="6390c49774a71f12831a08e3", + created_on=datetime.datetime.fromisoformat( + "2024-03-11 10:42:00+00:00", + ), + last_updated=datetime.datetime.fromisoformat( + "2024-03-11 10:42:42+00:00", + ), + archived=False, + draft=False, + can_branch=True, + seo=PageSeo( + title="The Ultimate Hitchhiker's Guide to the Galaxy", + description="Everything you need to know about the galaxy, from avoiding Vogon poetry to the importance of towels.", + ), + open_graph=PageOpenGraph( + title="Explore the Cosmos with The Ultimate Guide", + title_copied=False, + description="Dive deep into the mysteries of the universe with your guide to everything galactic.", + description_copied=False, + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**page_id:** `str` — Unique identifier for a Page + +
+
+ +
+
+ +**locale:** `typing.Optional[str]` — Unique identifier for a specific locale. Applicable, when using localization. + +
+
+ +
+
+ +**id:** `typing.Optional[str]` — Unique identifier for the Page + +
+
+ +
+
+ +**site_id:** `typing.Optional[str]` — Unique identifier for the Site + +
+
+ +
+
+ +**title:** `typing.Optional[str]` — Title of the Page + +
+
+ +
+
+ +**slug:** `typing.Optional[str]` — slug of the Page (derived from title) + +
+
+ +
+
+ +**parent_id:** `typing.Optional[str]` — Identifier of the parent folder + +
+
+ +
+
+ +**collection_id:** `typing.Optional[str]` — Unique identifier for a linked Collection, value will be null if the Page is not part of a Collection. + +
+
+ +
+
+ +**created_on:** `typing.Optional[dt.datetime]` — The date the Page was created + +
+
+ +
+
+ +**last_updated:** `typing.Optional[dt.datetime]` — The date the Page was most recently updated + +
+
+ +
+
+ +**archived:** `typing.Optional[bool]` — Whether the Page has been archived + +
+
+ +
+
+ +**draft:** `typing.Optional[bool]` — Whether the Page is a draft + +
+
+ +
+
+ +**can_branch:** `typing.Optional[bool]` — Indicates whether the Page supports [Page Branching](https://university.webflow.com/lesson/page-branching) + +
+
+ +
+
+ +**is_members_only:** `typing.Optional[bool]` — Indicates whether the Page is restricted by [Memberships Controls](https://university.webflow.com/lesson/webflow-memberships-overview#how-to-manage-page-restrictions) + +
+
+ +
+
+ +**seo:** `typing.Optional[PageSeo]` — SEO-related fields for the Page + +
+
+ +
+
+ +**open_graph:** `typing.Optional[PageOpenGraph]` — Open Graph fields for the Page + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.pages.get_content(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get static content from a static page.
If you do not provide a Locale ID in your request, the response will return any content that can be localized from the Primary locale

Required scope | `pages:read` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.pages.get_content( + page_id="page_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**page_id:** `str` — Unique identifier for a Page + +
+
+ +
+
+ +**locale:** `typing.Optional[str]` — Unique identifier for a specific locale. Applicable, when using localization. + +
+
+ +
+
+ +**limit:** `typing.Optional[float]` — Maximum number of records to be returned (max limit: 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[float]` — Offset used for pagination if the results have more than limit records + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.pages.update_static_content(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Update static content on a static page. This endpoint supports sending 1000 nodes per request.

Required scope | `pages:write` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow import DomWriteNodesItem +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.pages.update_static_content( + page_id="page_id", + locale="locale", + nodes=[ + DomWriteNodesItem( + node_id="a245c12d-995b-55ee-5ec7-aa36a6cad623", + text="

The Hitchhiker's Guide to the Galaxy

", + ), + DomWriteNodesItem( + node_id="a245c12d-995b-55ee-5ec7-aa36a6cad627", + text="

Don't Panic!

Always know where your towel is.

", + ), + DomWriteNodesItem( + node_id="a245c12d-995b-55ee-5ec7-aa36a6cad629", + text="Marvin, the Paranoid Android", + ), + ], +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**page_id:** `str` — Unique identifier for a Page + +
+
+ +
+
+ +**locale:** `str` — The locale identifier. + +
+
+ +
+
+ +**nodes:** `typing.Sequence[DomWriteNodesItem]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Pages Scripts +
client.pages.scripts.get_custom_code(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get all registered scripts that have been applied to a specific Page.

In order to use the Custom Code APIs for Sites and Pages, Custom Code Scripts must first be registered to a Site via the `registered_scripts` endpoints, and then applied to a Site or Page using the appropriate `custom_code` endpoints.
Access to this endpoint requires a bearer token from a Data Client App.
Required scope | `custom_code:read` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.pages.scripts.get_custom_code( + page_id="page_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**page_id:** `str` — Unique identifier for a Page + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.pages.scripts.upsert_custom_code(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Add a registered script to a Page.

In order to use the Custom Code APIs for Sites and Pages, Custom Code Scripts must first be registered to a Site via the `registered_scripts` endpoints, and then applied to a Site or Page using the appropriate `custom_code` endpoints.
Access to this endpoint requires a bearer token from a Data Client App.
Required scope | `custom_code:write` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow import ScriptApply, ScriptApplyLocation +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.pages.scripts.upsert_custom_code( + page_id="page_id", + scripts=[ + ScriptApply( + id="cms_slider", + location=ScriptApplyLocation.HEADER, + version="1.0.0", + attributes={"my-attribute": "some-value"}, + ), + ScriptApply( + id="alert", + location=ScriptApplyLocation.HEADER, + version="0.0.1", + ), + ], +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**page_id:** `str` — Unique identifier for a Page + +
+
+ +
+
+ +**scripts:** `typing.Optional[typing.Sequence[ScriptApply]]` — A list of scripts applied to a Site or a Page + +
+
+ +
+
+ +**last_updated:** `typing.Optional[str]` — Date when the Site's scripts were last updated + +
+
+ +
+
+ +**created_on:** `typing.Optional[str]` — Date when the Site's scripts were created + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.pages.scripts.delete_custom_code(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete the custom code block that an app has created for a page

In order to use the Custom Code APIs for Sites and Pages, Custom Code Scripts must first be registered to a Site via the `registered_scripts` endpoints, and then applied to a Site or Page using the appropriate `custom_code` endpoints.
Access to this endpoint requires a bearer token from a Data Client App.
Required scope | `custom_code:write` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.pages.scripts.delete_custom_code( + page_id="page_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**page_id:** `str` — Unique identifier for a Page + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Sites Scripts +
client.sites.scripts.get_custom_code(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get all registered scripts that have been applied to a specific Site.
Access to this endpoint requires a bearer token from a Data Client App.
Required scope | `custom_code:read` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.sites.scripts.get_custom_code( + site_id="site_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**site_id:** `str` — Unique identifier for a Site + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.sites.scripts.upsert_custom_code(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Add a registered script to a Site.

In order to use the Custom Code APIs for Sites and Pages, Custom Code Scripts must first be registered to a Site via the `registered_scripts` endpoints, and then applied to a Site or Page using the appropriate `custom_code` endpoints.
Access to this endpoint requires a bearer token from a Data Client App.
Required scope | `custom_code:write` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow import ScriptApply, ScriptApplyLocation +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.sites.scripts.upsert_custom_code( + site_id="site_id", + scripts=[ + ScriptApply( + id="cms_slider", + location=ScriptApplyLocation.HEADER, + version="1.0.0", + attributes={"my-attribute": "some-value"}, + ), + ScriptApply( + id="alert", + location=ScriptApplyLocation.HEADER, + version="0.0.1", + ), + ], +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**site_id:** `str` — Unique identifier for a Site + +
+
+ +
+
+ +**scripts:** `typing.Optional[typing.Sequence[ScriptApply]]` — A list of scripts applied to a Site or a Page + +
+
+ +
+
+ +**last_updated:** `typing.Optional[str]` — Date when the Site's scripts were last updated + +
+
+ +
+
+ +**created_on:** `typing.Optional[str]` — Date when the Site's scripts were created + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.sites.scripts.delete_custom_code(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete the custom code block that an app created for a Site

Access to this endpoint requires a bearer token from a Data Client App.
Required scope | `custom_code:write` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.sites.scripts.delete_custom_code( + site_id="site_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**site_id:** `str` — Unique identifier for a Site + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.sites.scripts.list_custom_code_blocks(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get all instances of Custom Code applied to a Site or Pages.
Access to this endpoint requires a bearer token from a Data Client App.
Required scope | `custom_code:read` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.sites.scripts.list_custom_code_blocks( + site_id="site_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**site_id:** `str` — Unique identifier for a Site + +
+
+ +
+
+ +**offset:** `typing.Optional[float]` — Offset used for pagination if the results have more than limit records + +
+
+ +
+
+ +**limit:** `typing.Optional[float]` — Maximum number of records to be returned (max limit: 100) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Scripts +
client.scripts.list(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +List of scripts registered to a Site.

In order to use the Custom Code APIs for Sites and Pages, Custom Code Scripts must first be registered to a Site via the `registered_scripts` endpoints, and then applied to a Site or Page using the appropriate `custom_code` endpoints. Additionally, Scripts can be remotely hosted, or registered as inline snippets.
Access to this endpoint requires a bearer token from a Data Client App.
Required scope | `custom_code:read` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.scripts.list( + site_id="site_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**site_id:** `str` — Unique identifier for a Site + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.scripts.register_hosted(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Add a script to a Site's Custom Code registry.

In order to use the Custom Code APIs for Sites and Pages, Custom Code Scripts must first be registered to a Site via the `registered_scripts` endpoints, and then applied to a Site or Page using the appropriate `custom_code` endpoints. Additionally, Scripts can be remotely hosted, or registered as inline snippets.
Access to this endpoint requires a bearer token from a Data Client App.


Required scope | `custom_code:write` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.scripts.register_hosted( + site_id="site_id", + hosted_location="hostedLocation", + integrity_hash="integrityHash", + version="version", + display_name="displayName", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**site_id:** `str` — Unique identifier for a Site + +
+
+ +
+
+ +**hosted_location:** `str` — URI for an externally hosted script location + +
+
+ +
+
+ +**integrity_hash:** `str` — Sub-Resource Integrity Hash + +
+
+ +
+
+ +**version:** `str` — A Semantic Version (SemVer) string, denoting the version of the script + +
+
+ +
+
+ +**display_name:** `str` — User-facing name for the script. Must be between 1 and 50 alphanumeric characters + +
+
+ +
+
+ +**can_copy:** `typing.Optional[bool]` — Define whether the script can be copied on site duplication and transfer + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.scripts.register_inline(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Add a script to a Site's Custom Code registry. Inline scripts can be between 1 and 2000 characters.

In order to use the Custom Code APIs for Sites and Pages, Custom Code Scripts must first be registered to a Site via the `registered_scripts` endpoints, and then applied to a Site or Page using the appropriate `custom_code` endpoints.

Access to this endpoint requires a bearer token from a Data Client App.
Required scope | `custom_code:write` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.scripts.register_inline( + site_id="site_id", + source_code="alert('hello world');", + version="0.0.1", + display_name="Alert", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**site_id:** `str` — Unique identifier for a Site + +
+
+ +
+
+ +**source_code:** `str` — The code to be added to the site (to be hosted by Webflow). + +
+
+ +
+
+ +**version:** `str` — A Semantic Version (SemVer) string, denoting the version of the script + +
+
+ +
+
+ +**display_name:** `str` — User-facing name for the script. Must be between 1 and 50 alphanumeric characters + +
+
+ +
+
+ +**integrity_hash:** `typing.Optional[str]` — Sub-Resource Integrity Hash. Only required for externally hosted scripts (passed via hostedLocation) + +
+
+ +
+
+ +**can_copy:** `typing.Optional[bool]` — Define whether the script can be copied on site duplication and transfer + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Assets +
client.assets.list(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +List assets for a given site

Required scope | `assets:read` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.assets.list( + site_id="site_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**site_id:** `str` — Unique identifier for a Site + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.assets.create(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create a new asset entry.

This endpoint generates a response with the following information: `uploadUrl` and `uploadDetails`. You can use these two properties to [upload the file to Amazon s3 by making a POST](https://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectPOST.html) request to the `uploadUrl` with the `uploadDetails` object as your header information in the request.

Required scope | `assets:write` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.assets.create( + site_id="site_id", + file_name="file.png", + file_hash="3c7d87c9575702bc3b1e991f4d3c638e", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**site_id:** `str` — Unique identifier for a Site + +
+
+ +
+
+ +**file_name:** `str` — file name including file extension + +
+
+ +
+
+ +**file_hash:** `str` — MD5 hash of the file + +
+
+ +
+
+ +**parent_folder:** `typing.Optional[str]` — id of the Asset folder (optional) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.assets.get(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get an Asset

Required scope | `assets:read` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.assets.get( + asset_id="asset_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**asset_id:** `str` — Unique identifier for an Asset on a site + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.assets.delete(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete an Asset +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.assets.delete( + asset_id="asset_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**asset_id:** `str` — Unique identifier for an Asset on a site + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.assets.update(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Update an Asset

Required scope | `assets:write` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.assets.update( + asset_id="asset_id", + display_name="bulldoze.png", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**asset_id:** `str` — Unique identifier for an Asset on a site + +
+
+ +
+
+ +**display_name:** `str` — file name including file extension + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.assets.list_folders(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +List Asset Folders within a given site

Required scope | `assets:read` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.assets.list_folders( + site_id="site_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**site_id:** `str` — Unique identifier for a Site + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.assets.create_folder(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create an Asset Folder within a given site

Required scope | `assets:write` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.assets.create_folder( + site_id="site_id", + display_name="my asset folder", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**site_id:** `str` — Unique identifier for a Site + +
+
+ +
+
+ +**display_name:** `str` — A human readable name for the Asset Folder + +
+
+ +
+
+ +**parent_folder:** `typing.Optional[str]` — An (optional) pointer to a parent Asset Folder (or null for root) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.assets.get_folder(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get details about a specific Asset Folder

Required scope | `assets:read` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.assets.get_folder( + asset_folder_id="asset_folder_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**asset_folder_id:** `str` — Unique identifier for an Asset Folder + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Webhooks +
client.webhooks.list(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +List all App-created Webhooks registered for a given site

Required scope | `sites:read` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.webhooks.list( + site_id="site_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**site_id:** `str` — Unique identifier for a Site + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.webhooks.create(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create a new Webhook, to be notified when Webflow resources change. Limit of 75 registrations per `triggerType`, per site.
Access to this endpoint requires a bearer token from a Data Client App.
Required scope | `sites:write` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow import TriggerType +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.webhooks.create( + site_id="site_id", + trigger_type=TriggerType.FORM_SUBMISSION, + url="https://api.mydomain.com/webhook", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**site_id:** `str` — Unique identifier for a Site + +
+
+ +
+
+ +**trigger_type:** `TriggerType` + +
+
+ +
+
+ +**url:** `str` — The server URI that Webflow will call when your Webhook is triggered + + +
+
+ +
+
+ +**filter:** `typing.Optional[typing.Dict[str, typing.Any]]` + +Filter for selecting which events you want Webhooks to be triggered for. +** Only available for `form_submission` trigger types. ** + + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.webhooks.get(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get a specific Webhook instance +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.webhooks.get( + webhook_id="webhook_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**webhook_id:** `str` — Unique identifier for a Webhook + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.webhooks.delete(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Remove a Webhook +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.webhooks.delete( + webhook_id="webhook_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**webhook_id:** `str` — Unique identifier for a Webhook + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Forms +
client.forms.list(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +List forms for a given site

Required scope | `forms:read` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.forms.list( + site_id="site_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**site_id:** `str` — Unique identifier for a Site + +
+
+ +
+
+ +**limit:** `typing.Optional[float]` — Maximum number of records to be returned (max limit: 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[float]` — Offset used for pagination if the results have more than limit records + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.forms.get(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get information about a given form

Required scope | `forms:read` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.forms.get( + form_id="form_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**form_id:** `str` — Unique identifier for a Form + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.forms.list_submissions(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +List form submissions for a given form

Required scope | `forms:read` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.forms.list_submissions( + form_id="form_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**form_id:** `str` — Unique identifier for a Form + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.forms.get_submission(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get information about a given form submission

Required scope | `forms:read` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.forms.get_submission( + form_submission_id="form_submission_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**form_submission_id:** `str` — Unique identifier for a Form Submission + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.forms.update_submission(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Update hidden fields on a form submission

Required scope | `forms:write` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.forms.update_submission( + form_submission_id="form_submission_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**form_submission_id:** `str` — Unique identifier for a Form Submission + +
+
+ +
+
+ +**form_submission_data:** `typing.Optional[typing.Dict[str, typing.Any]]` — An existing **hidden field** defined on the form schema, and the corresponding value to set + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Users +
client.users.list(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get a list of users for a site

Required scope | `users:read` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.users.list( + site_id="site_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**site_id:** `str` — Unique identifier for a Site + +
+
+ +
+
+ +**offset:** `typing.Optional[float]` — Offset used for pagination if the results have more than limit records + +
+
+ +
+
+ +**limit:** `typing.Optional[float]` — Maximum number of records to be returned (max limit: 100) + +
+
+ +
+
+ +**sort:** `typing.Optional[UsersListRequestSort]` + +Sort string to use when ordering users + +Example(`CreatedOn`, `Email`, `Status`, `LastLogin`, `UpdatedOn`). + +Can be prefixed with a `-` to reverse the sort (ex. `-CreatedOn`) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.users.get(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get a User by ID

Required scope | `users:read` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.users.get( + site_id="site_id", + user_id="user_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**site_id:** `str` — Unique identifier for a Site + +
+
+ +
+
+ +**user_id:** `str` — Unique identifier for a User + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.users.delete(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete a User by ID

Required scope | `users:write` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.users.delete( + site_id="site_id", + user_id="user_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**site_id:** `str` — Unique identifier for a Site + +
+
+ +
+
+ +**user_id:** `str` — Unique identifier for a User + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.users.update(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Update a User by ID

Required scope | `users:write` + + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow import UsersUpdateRequestData +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.users.update( + site_id="site_id", + user_id="user_id", + data=UsersUpdateRequestData( + name="Some One", + accept_privacy=False, + accept_communications=False, + ), + access_groups=["webflowers", "platinum", "free-tier"], +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**site_id:** `str` — Unique identifier for a Site + +
+
+ +
+
+ +**user_id:** `str` — Unique identifier for a User + +
+
+ +
+
+ +**data:** `typing.Optional[UsersUpdateRequestData]` + +
+
+ +
+
+ +**access_groups:** `typing.Optional[typing.Sequence[str]]` — An array of access group slugs. Access groups are assigned to the user as type `admin` and the user remains in the group until removed. + + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.users.invite(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create and invite a user with an email address. The user will be sent and invite via email, which they will need to accept in order to join paid Access Groups.

Required scope | `users:write` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.users.invite( + site_id="site_id", + email="some.one@home.com", + access_groups=["webflowers"], +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**site_id:** `str` — Unique identifier for a Site + +
+
+ +
+
+ +**email:** `str` — Email address of user to send invite to + +
+
+ +
+
+ +**access_groups:** `typing.Optional[typing.Sequence[str]]` — An array of access group slugs. Access groups are assigned to the user as type `admin` and the user remains in the group until removed. + + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## AccessGroups +
client.access_groups.list(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get a list of access groups for a site

Required scope | `users:read` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.access_groups.list( + site_id="site_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**site_id:** `str` — Unique identifier for a Site + +
+
+ +
+
+ +**offset:** `typing.Optional[float]` — Offset used for pagination if the results have more than limit records + +
+
+ +
+
+ +**limit:** `typing.Optional[float]` — Maximum number of records to be returned (max limit: 100) + +
+
+ +
+
+ +**sort:** `typing.Optional[AccessGroupsListRequestSort]` + +Sort string to use when ordering access groups +Can be prefixed with a `-` to reverse the sort (ex. `-CreatedOn`) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Products +
client.products.list(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve all products for a site. Use `limit` and `offset` to page through all products with subsequent requests. All SKUs for each product will also be fetched and returned. The `limit`, `offset` and `total` values represent Products only and do not include any SKUs. + +Required scope | `ecommerce:read` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.products.list( + site_id="site_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**site_id:** `str` — Unique identifier for a Site + +
+
+ +
+
+ +**offset:** `typing.Optional[float]` — Offset used for pagination if the results have more than limit records + +
+
+ +
+
+ +**limit:** `typing.Optional[float]` — Maximum number of records to be returned (max limit: 100) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.products.create(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Creating a new Product involves creating both a Product and a SKU, since a Product Item has to have, at minimum, a single SKU. + +In order to create a Product with multiple SKUs - for example a T-shirt in sizes small, medium and large - you'll need to create `sku-properties`. In our T-shirt example, a single `sku-property` would be Color. Within that property, we'll need to list out the various colors a T-shirt could be as an array of `enum` values: `royal-blue`, `crimson-red`, and `forrest-green`. + +Once, you've created a Product and its `sku-properties` with `enum` values, you can create your default SKU, which will automatically be a combination of the first `sku-properties` you've created. In our example, the default SKU will be a Royal Blue T-Shirt, because our first `enum` of our Color `sku-property` is Royal Blue. After you've created your product, you can create additional SKUs using the Create SKU endpoint + +Upon creation, the default product type will be `Advanced`. The product type is used to determine which Product and SKU fields are shown to users in the `Designer` and the `Editor`. Setting it to `Advanced` ensures that all Product and SKU fields will be shown. + +Required scope | `ecommerce:write` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.products.create( + site_id="site_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**site_id:** `str` — Unique identifier for a Site + +
+
+ +
+
+ +**publish_status:** `typing.Optional[PublishStatus]` + +
+
+ +
+
+ +**product:** `typing.Optional[Product]` + +
+
+ +
+
+ +**sku:** `typing.Optional[Sku]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.products.get(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve a single product by its id. All of its SKUs will also be retrieved. + +Required scope | `ecommerce:read` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.products.get( + site_id="site_id", + product_id="product_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**site_id:** `str` — Unique identifier for a Site + +
+
+ +
+
+ +**product_id:** `str` — Unique identifier for a Product + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.products.update(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Updating an existing Product will set the product type to `Advanced`. The product type is used to determine which Product and SKU fields are shown to users in the `Designer` and the `Editor`. Setting it to `Advanced` ensures that all Product and SKU fields will be shown. The product type can be edited in the `Designer` or the `Editor`. + +Required scope | `ecommerce:write` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.products.update( + site_id="site_id", + product_id="product_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**site_id:** `str` — Unique identifier for a Site + +
+
+ +
+
+ +**product_id:** `str` — Unique identifier for a Product + +
+
+ +
+
+ +**publish_status:** `typing.Optional[PublishStatus]` + +
+
+ +
+
+ +**product:** `typing.Optional[Product]` + +
+
+ +
+
+ +**sku:** `typing.Optional[Sku]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.products.create_sku(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create additional SKUs to cover every variant of your Product. The Default SKU already counts as one of the variants. + +Creating additional SKUs will set the product type to `Advanced` for the product associated with the SKUs. The product type is used to determine which Product and SKU fields are shown to users in the `Designer` and the `Editor`. Setting it to `Advanced` ensures that all Product and SKU fields will be shown. The product type can be edited in the `Designer` or the `Editor`. + +Required scope | `ecommerce:write` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow import Sku +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.products.create_sku( + site_id="site_id", + product_id="product_id", + skus=[Sku()], +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**site_id:** `str` — Unique identifier for a Site + +
+
+ +
+
+ +**product_id:** `str` — Unique identifier for a Product + +
+
+ +
+
+ +**skus:** `typing.Sequence[Sku]` — An array of the SKU data your are adding + +
+
+ +
+
+ +**publish_status:** `typing.Optional[PublishStatus]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.products.update_sku(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Updating an existing SKU will set the product type to `Advanced` for the product associated with the SKU. The product type is used to determine which Product and SKU fields are shown to users in the `Designer` and the `Editor`. Setting it to `Advanced` ensures that all Product and SKU fields will be shown. The product type can be edited in the `Designer` or the `Editor`. + +Required scope | `ecommerce:write` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow import Sku +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.products.update_sku( + site_id="site_id", + product_id="product_id", + sku_id="sku_id", + sku=Sku(), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**site_id:** `str` — Unique identifier for a Site + +
+
+ +
+
+ +**product_id:** `str` — Unique identifier for a Product + +
+
+ +
+
+ +**sku_id:** `str` — Unique identifier for a SKU + +
+
+ +
+
+ +**sku:** `Sku` + +
+
+ +
+
+ +**publish_status:** `typing.Optional[PublishStatus]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Orders +
client.orders.list(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +List all orders created for a given site. + +Required scope | `ecommerce:read` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.orders.list( + site_id="site_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**site_id:** `str` — Unique identifier for a Site + +
+
+ +
+
+ +**status:** `typing.Optional[OrdersListRequestStatus]` — Filter the orders by status + +
+
+ +
+
+ +**offset:** `typing.Optional[float]` — Offset used for pagination if the results have more than limit records + +
+
+ +
+
+ +**limit:** `typing.Optional[float]` — Maximum number of records to be returned (max limit: 100) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.orders.get(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve a single product by its id. All of its SKUs will also be retrieved. + +Required scope | `ecommerce:read` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.orders.get( + site_id="site_id", + order_id="order_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**site_id:** `str` — Unique identifier for a Site + +
+
+ +
+
+ +**order_id:** `str` — Unique identifier for an Order + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.orders.update(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +This API lets you update the fields, `comment`, `shippingProvider`, and/or `shippingTracking` for a given order. All three fields can be updated simultaneously or independently. + +Required scope | `ecommerce:write` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.orders.update( + site_id="site_id", + order_id="order_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**site_id:** `str` — Unique identifier for a Site + +
+
+ +
+
+ +**order_id:** `str` — Unique identifier for an Order + +
+
+ +
+
+ +**comment:** `typing.Optional[str]` — Arbitrary data for your records + +
+
+ +
+
+ +**shipping_provider:** `typing.Optional[str]` — Company or method used to ship order + +
+
+ +
+
+ +**shipping_tracking:** `typing.Optional[str]` — Tracking number for order shipment + +
+
+ +
+
+ +**shipping_tracking_url:** `typing.Optional[str]` — URL to track order shipment + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.orders.update_fulfill(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Updates an order's status to fulfilled + +Required scope | `ecommerce:write` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.orders.update_fulfill( + site_id="site_id", + order_id="order_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**site_id:** `str` — Unique identifier for a Site + +
+
+ +
+
+ +**order_id:** `str` — Unique identifier for an Order + +
+
+ +
+
+ +**send_order_fulfilled_email:** `typing.Optional[bool]` — Whether or not the Order Fulfilled email should be sent + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.orders.update_unfulfill(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Updates an order's status to unfulfilled + +Required scope | `ecommerce:write` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.orders.update_unfulfill( + site_id="site_id", + order_id="order_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**site_id:** `str` — Unique identifier for a Site + +
+
+ +
+
+ +**order_id:** `str` — Unique identifier for an Order + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.orders.refund(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +This API will reverse a Stripe charge and refund an order back to a +customer. It will also set the order's status to `refunded`. + +Required scope | `ecommerce:write` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.orders.refund( + site_id="site_id", + order_id="order_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**site_id:** `str` — Unique identifier for a Site + +
+
+ +
+
+ +**order_id:** `str` — Unique identifier for an Order + +
+
+ +
+
+ +**reason:** `typing.Optional[OrdersRefundRequestReason]` — The reason for the refund + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Inventory +
client.inventory.list(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +List the current inventory levels for a particular SKU item. + +Required scope | `ecommerce:read` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.inventory.list( + collection_id="collection_id", + item_id="item_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**collection_id:** `str` — Unique identifier for a Collection + +
+
+ +
+
+ +**item_id:** `str` — Unique identifier for an Item + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.inventory.update(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Updates the current inventory levels for a particular SKU item. Updates may be given in one or two methods, absolutely or incrementally. Absolute updates are done by setting `quantity` directly. Incremental updates are by specifying the inventory delta in `updateQuantity` which is then added to the `quantity` stored on the server. + +Required scope | `ecommerce:write` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow import InventoryUpdateRequestInventoryType +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.inventory.update( + collection_id="collection_id", + item_id="item_id", + inventory_type=InventoryUpdateRequestInventoryType.INFINITE, +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**collection_id:** `str` — Unique identifier for a Collection + +
+
+ +
+
+ +**item_id:** `str` — Unique identifier for an Item + +
+
+ +
+
+ +**inventory_type:** `InventoryUpdateRequestInventoryType` — infinite or finite + +
+
+ +
+
+ +**update_quantity:** `typing.Optional[float]` — Adds this quantity to currently store quantity. Can be negative. + +
+
+ +
+
+ +**quantity:** `typing.Optional[float]` — Immediately sets quantity to this value. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Ecommerce +
client.ecommerce.get_settings(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve ecommerce settings for a site. + +Required scope | `ecommerce:read` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from webflow.client import Webflow + +client = Webflow( + access_token="YOUR_ACCESS_TOKEN", +) +client.ecommerce.get_settings( + site_id="site_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**site_id:** `str` — Unique identifier for a Site + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ diff --git a/src/webflow/__init__.py b/src/webflow/__init__.py index 7d4de99..45e46b7 100644 --- a/src/webflow/__init__.py +++ b/src/webflow/__init__.py @@ -15,6 +15,7 @@ AuthorizationAuthorization, AuthorizationAuthorizationAuthorizedTo, AuthorizedUser, + BadRequestErrorBody, Collection, CollectionItem, CollectionItemFieldData, @@ -22,9 +23,11 @@ CollectionItemListPagination, CollectionList, CollectionListArrayItem, + ConflictErrorBody, CustomCodeBlock, CustomCodeBlockType, - CustomCodeResponse, + CustomCodeHostedResponse, + CustomCodeInlineResponse, Dom, Domain, Domains, @@ -34,6 +37,7 @@ ErrorDetailsItem, Field, FieldType, + ForbiddenErrorBody, Form, FormField, FormFieldValue, @@ -47,6 +51,8 @@ InventoryItem, InventoryItemInventoryType, ListCustomCodeBlocks, + Locale, + Locales, MissingScopes, NoDomains, Node, @@ -72,6 +78,9 @@ OrderTotalsExtrasItem, OrderTotalsExtrasItemType, Page, + PageDetails, + PageDetailsOpenGraph, + PageDetailsSeo, PageList, PageOpenGraph, PageSeo, @@ -94,12 +103,15 @@ SiteActivityLogItemResourceOperation, SiteActivityLogItemUser, SiteActivityLogResponse, + Sites, Sku, SkuFieldData, SkuFieldDataCompareAtPrice, SkuFieldDataEcSkuBillingMethod, SkuFieldDataEcSkuSubscriptionPlan, SkuFieldDataEcSkuSubscriptionPlanInterval, + SkuFieldDataEcSkuSubscriptionPlanPlansItem, + SkuFieldDataEcSkuSubscriptionPlanPlansItemStatus, SkuFieldDataPrice, SkuPropertyList, SkuPropertyListEnumItem, @@ -135,19 +147,10 @@ AccessGroupsListRequestSort, DomWriteNodesItem, InventoryUpdateRequestInventoryType, + OrdersListRequestStatus, OrdersRefundRequestReason, - ProductSkuCreateProduct, - ProductSkuCreateProductFieldData, - ProductSkuCreateProductFieldDataEcProductType, - ProductSkuCreateProductFieldDataTaxCategory, - ProductSkuCreateSku, - ProductSkuCreateSkuFieldData, - ProductSkuCreateSkuFieldDataCompareAtPrice, - ProductSkuCreateSkuFieldDataEcSkuBillingMethod, - ProductSkuCreateSkuFieldDataEcSkuSubscriptionPlan, - ProductSkuCreateSkuFieldDataEcSkuSubscriptionPlanInterval, - ProductSkuCreateSkuFieldDataPrice, ProductsCreateSkuResponse, + UpdateStaticContentResponse, UsersListRequestSort, UsersUpdateRequestData, access_groups, @@ -166,6 +169,7 @@ webhooks, ) from .environment import WebflowEnvironment +from .version import __version__ __all__ = [ "AccessGroup", @@ -184,6 +188,7 @@ "AuthorizationAuthorizationAuthorizedTo", "AuthorizedUser", "BadRequestError", + "BadRequestErrorBody", "Collection", "CollectionItem", "CollectionItemFieldData", @@ -192,9 +197,11 @@ "CollectionList", "CollectionListArrayItem", "ConflictError", + "ConflictErrorBody", "CustomCodeBlock", "CustomCodeBlockType", - "CustomCodeResponse", + "CustomCodeHostedResponse", + "CustomCodeInlineResponse", "Dom", "DomWriteNodesItem", "Domain", @@ -206,6 +213,7 @@ "Field", "FieldType", "ForbiddenError", + "ForbiddenErrorBody", "Form", "FormField", "FormFieldValue", @@ -221,6 +229,8 @@ "InventoryItemInventoryType", "InventoryUpdateRequestInventoryType", "ListCustomCodeBlocks", + "Locale", + "Locales", "MissingScopes", "NoDomains", "Node", @@ -246,8 +256,12 @@ "OrderTotals", "OrderTotalsExtrasItem", "OrderTotalsExtrasItemType", + "OrdersListRequestStatus", "OrdersRefundRequestReason", "Page", + "PageDetails", + "PageDetailsOpenGraph", + "PageDetailsSeo", "PageList", "PageOpenGraph", "PageSeo", @@ -259,17 +273,6 @@ "ProductFieldData", "ProductFieldDataEcProductType", "ProductFieldDataTaxCategory", - "ProductSkuCreateProduct", - "ProductSkuCreateProductFieldData", - "ProductSkuCreateProductFieldDataEcProductType", - "ProductSkuCreateProductFieldDataTaxCategory", - "ProductSkuCreateSku", - "ProductSkuCreateSkuFieldData", - "ProductSkuCreateSkuFieldDataCompareAtPrice", - "ProductSkuCreateSkuFieldDataEcSkuBillingMethod", - "ProductSkuCreateSkuFieldDataEcSkuSubscriptionPlan", - "ProductSkuCreateSkuFieldDataEcSkuSubscriptionPlanInterval", - "ProductSkuCreateSkuFieldDataPrice", "ProductsCreateSkuResponse", "PublishStatus", "RegisteredScriptList", @@ -282,12 +285,15 @@ "SiteActivityLogItemResourceOperation", "SiteActivityLogItemUser", "SiteActivityLogResponse", + "Sites", "Sku", "SkuFieldData", "SkuFieldDataCompareAtPrice", "SkuFieldDataEcSkuBillingMethod", "SkuFieldDataEcSkuSubscriptionPlan", "SkuFieldDataEcSkuSubscriptionPlanInterval", + "SkuFieldDataEcSkuSubscriptionPlanPlansItem", + "SkuFieldDataEcSkuSubscriptionPlanPlansItemStatus", "SkuFieldDataPrice", "SkuPropertyList", "SkuPropertyListEnumItem", @@ -300,6 +306,7 @@ "TooManyRequestsError", "TriggerType", "UnauthorizedError", + "UpdateStaticContentResponse", "User", "UserAccessGroupsItem", "UserAccessGroupsItemType", @@ -314,6 +321,7 @@ "WebflowEnvironment", "Webhook", "WebhookList", + "__version__", "access_groups", "assets", "collections", diff --git a/src/webflow/client.py b/src/webflow/client.py index 493b3bd..2a602d9 100644 --- a/src/webflow/client.py +++ b/src/webflow/client.py @@ -24,21 +24,34 @@ class Webflow: """ - Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propogate to these functions. + Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions. - Parameters: - - base_url: typing.Optional[str]. The base url to use for requests from the client. + Parameters + ---------- + base_url : typing.Optional[str] + The base url to use for requests from the client. - - environment: WebflowEnvironment. The environment to use for requests from the client. from .environment import WebflowEnvironment + environment : WebflowEnvironment + The environment to use for requests from the client. from .environment import WebflowEnvironment - Defaults to WebflowEnvironment.DEFAULT - - access_token: typing.Union[str, typing.Callable[[], str]]. - - timeout: typing.Optional[float]. The timeout to be used, in seconds, for requests by default the timeout is 60 seconds. + Defaults to WebflowEnvironment.DEFAULT - - httpx_client: typing.Optional[httpx.Client]. The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration. - --- + + + access_token : typing.Union[str, typing.Callable[[], str]] + timeout : typing.Optional[float] + The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced. + + follow_redirects : typing.Optional[bool] + Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in. + + httpx_client : typing.Optional[httpx.Client] + The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration. + + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -52,13 +65,20 @@ def __init__( base_url: typing.Optional[str] = None, environment: WebflowEnvironment = WebflowEnvironment.DEFAULT, access_token: typing.Union[str, typing.Callable[[], str]], - timeout: typing.Optional[float] = 60, + timeout: typing.Optional[float] = None, + follow_redirects: typing.Optional[bool] = True, httpx_client: typing.Optional[httpx.Client] = None ): + _defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None self._client_wrapper = SyncClientWrapper( base_url=_get_base_url(base_url=base_url, environment=environment), access_token=access_token, - httpx_client=httpx.Client(timeout=timeout) if httpx_client is None else httpx_client, + httpx_client=httpx_client + if httpx_client is not None + else httpx.Client(timeout=_defaulted_timeout, follow_redirects=follow_redirects) + if follow_redirects is not None + else httpx.Client(timeout=_defaulted_timeout), + timeout=_defaulted_timeout, ) self.token = TokenClient(client_wrapper=self._client_wrapper) self.sites = SitesClient(client_wrapper=self._client_wrapper) @@ -78,21 +98,34 @@ def __init__( class AsyncWebflow: """ - Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propogate to these functions. + Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions. + + Parameters + ---------- + base_url : typing.Optional[str] + The base url to use for requests from the client. + + environment : WebflowEnvironment + The environment to use for requests from the client. from .environment import WebflowEnvironment + + + + Defaults to WebflowEnvironment.DEFAULT - Parameters: - - base_url: typing.Optional[str]. The base url to use for requests from the client. - - environment: WebflowEnvironment. The environment to use for requests from the client. from .environment import WebflowEnvironment - Defaults to WebflowEnvironment.DEFAULT + access_token : typing.Union[str, typing.Callable[[], str]] + timeout : typing.Optional[float] + The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced. - - access_token: typing.Union[str, typing.Callable[[], str]]. + follow_redirects : typing.Optional[bool] + Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in. - - timeout: typing.Optional[float]. The timeout to be used, in seconds, for requests by default the timeout is 60 seconds. + httpx_client : typing.Optional[httpx.AsyncClient] + The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration. - - httpx_client: typing.Optional[httpx.AsyncClient]. The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration. - --- + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -106,13 +139,20 @@ def __init__( base_url: typing.Optional[str] = None, environment: WebflowEnvironment = WebflowEnvironment.DEFAULT, access_token: typing.Union[str, typing.Callable[[], str]], - timeout: typing.Optional[float] = 60, + timeout: typing.Optional[float] = None, + follow_redirects: typing.Optional[bool] = True, httpx_client: typing.Optional[httpx.AsyncClient] = None ): + _defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None self._client_wrapper = AsyncClientWrapper( base_url=_get_base_url(base_url=base_url, environment=environment), access_token=access_token, - httpx_client=httpx.AsyncClient(timeout=timeout) if httpx_client is None else httpx_client, + httpx_client=httpx_client + if httpx_client is not None + else httpx.AsyncClient(timeout=_defaulted_timeout, follow_redirects=follow_redirects) + if follow_redirects is not None + else httpx.AsyncClient(timeout=_defaulted_timeout), + timeout=_defaulted_timeout, ) self.token = AsyncTokenClient(client_wrapper=self._client_wrapper) self.sites = AsyncSitesClient(client_wrapper=self._client_wrapper) diff --git a/src/webflow/core/__init__.py b/src/webflow/core/__init__.py index 4c53b36..58ad52a 100644 --- a/src/webflow/core/__init__.py +++ b/src/webflow/core/__init__.py @@ -4,19 +4,27 @@ from .client_wrapper import AsyncClientWrapper, BaseClientWrapper, SyncClientWrapper from .datetime_utils import serialize_datetime from .file import File, convert_file_dict_to_httpx_tuples +from .http_client import AsyncHttpClient, HttpClient from .jsonable_encoder import jsonable_encoder +from .pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from .query_encoder import encode_query from .remove_none_from_dict import remove_none_from_dict from .request_options import RequestOptions __all__ = [ "ApiError", "AsyncClientWrapper", + "AsyncHttpClient", "BaseClientWrapper", "File", + "HttpClient", "RequestOptions", "SyncClientWrapper", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", + "encode_query", "jsonable_encoder", + "pydantic_v1", "remove_none_from_dict", "serialize_datetime", ] diff --git a/src/webflow/core/client_wrapper.py b/src/webflow/core/client_wrapper.py index 59bbfde..f8b1535 100644 --- a/src/webflow/core/client_wrapper.py +++ b/src/webflow/core/client_wrapper.py @@ -4,17 +4,26 @@ import httpx +from .http_client import AsyncHttpClient, HttpClient + class BaseClientWrapper: - def __init__(self, *, access_token: typing.Union[str, typing.Callable[[], str]], base_url: str): + def __init__( + self, + *, + access_token: typing.Union[str, typing.Callable[[], str]], + base_url: str, + timeout: typing.Optional[float] = None, + ): self._access_token = access_token self._base_url = base_url + self._timeout = timeout def get_headers(self) -> typing.Dict[str, str]: headers: typing.Dict[str, str] = { "X-Fern-Language": "Python", "X-Fern-SDK-Name": "webflow", - "X-Fern-SDK-Version": "v1.2.0", + "X-Fern-SDK-Version": "1.2.2", } headers["Authorization"] = f"Bearer {self._get_access_token()}" return headers @@ -28,13 +37,26 @@ def _get_access_token(self) -> str: def get_base_url(self) -> str: return self._base_url + def get_timeout(self) -> typing.Optional[float]: + return self._timeout + class SyncClientWrapper(BaseClientWrapper): def __init__( - self, *, access_token: typing.Union[str, typing.Callable[[], str]], base_url: str, httpx_client: httpx.Client + self, + *, + access_token: typing.Union[str, typing.Callable[[], str]], + base_url: str, + timeout: typing.Optional[float] = None, + httpx_client: httpx.Client, ): - super().__init__(access_token=access_token, base_url=base_url) - self.httpx_client = httpx_client + super().__init__(access_token=access_token, base_url=base_url, timeout=timeout) + self.httpx_client = HttpClient( + httpx_client=httpx_client, + base_headers=self.get_headers(), + base_timeout=self.get_timeout(), + base_url=self.get_base_url(), + ) class AsyncClientWrapper(BaseClientWrapper): @@ -43,7 +65,13 @@ def __init__( *, access_token: typing.Union[str, typing.Callable[[], str]], base_url: str, + timeout: typing.Optional[float] = None, httpx_client: httpx.AsyncClient, ): - super().__init__(access_token=access_token, base_url=base_url) - self.httpx_client = httpx_client + super().__init__(access_token=access_token, base_url=base_url, timeout=timeout) + self.httpx_client = AsyncHttpClient( + httpx_client=httpx_client, + base_headers=self.get_headers(), + base_timeout=self.get_timeout(), + base_url=self.get_base_url(), + ) diff --git a/src/webflow/core/http_client.py b/src/webflow/core/http_client.py new file mode 100644 index 0000000..09c6836 --- /dev/null +++ b/src/webflow/core/http_client.py @@ -0,0 +1,475 @@ +# This file was auto-generated by Fern from our API Definition. + +import asyncio +import email.utils +import json +import re +import time +import typing +import urllib.parse +from contextlib import asynccontextmanager, contextmanager +from random import random + +import httpx + +from .file import File, convert_file_dict_to_httpx_tuples +from .jsonable_encoder import jsonable_encoder +from .query_encoder import encode_query +from .remove_none_from_dict import remove_none_from_dict +from .request_options import RequestOptions + +INITIAL_RETRY_DELAY_SECONDS = 0.5 +MAX_RETRY_DELAY_SECONDS = 10 +MAX_RETRY_DELAY_SECONDS_FROM_HEADER = 30 + + +def _parse_retry_after(response_headers: httpx.Headers) -> typing.Optional[float]: + """ + This function parses the `Retry-After` header in a HTTP response and returns the number of seconds to wait. + + Inspired by the urllib3 retry implementation. + """ + retry_after_ms = response_headers.get("retry-after-ms") + if retry_after_ms is not None: + try: + return int(retry_after_ms) / 1000 if retry_after_ms > 0 else 0 + except Exception: + pass + + retry_after = response_headers.get("retry-after") + if retry_after is None: + return None + + # Attempt to parse the header as an int. + if re.match(r"^\s*[0-9]+\s*$", retry_after): + seconds = float(retry_after) + # Fallback to parsing it as a date. + else: + retry_date_tuple = email.utils.parsedate_tz(retry_after) + if retry_date_tuple is None: + return None + if retry_date_tuple[9] is None: # Python 2 + # Assume UTC if no timezone was specified + # On Python2.7, parsedate_tz returns None for a timezone offset + # instead of 0 if no timezone is given, where mktime_tz treats + # a None timezone offset as local time. + retry_date_tuple = retry_date_tuple[:9] + (0,) + retry_date_tuple[10:] + + retry_date = email.utils.mktime_tz(retry_date_tuple) + seconds = retry_date - time.time() + + if seconds < 0: + seconds = 0 + + return seconds + + +def _retry_timeout(response: httpx.Response, retries: int) -> float: + """ + Determine the amount of time to wait before retrying a request. + This function begins by trying to parse a retry-after header from the response, and then proceeds to use exponential backoff + with a jitter to determine the number of seconds to wait. + """ + + # If the API asks us to wait a certain amount of time (and it's a reasonable amount), just do what it says. + retry_after = _parse_retry_after(response.headers) + if retry_after is not None and retry_after <= MAX_RETRY_DELAY_SECONDS_FROM_HEADER: + return retry_after + + # Apply exponential backoff, capped at MAX_RETRY_DELAY_SECONDS. + retry_delay = min(INITIAL_RETRY_DELAY_SECONDS * pow(2.0, retries), MAX_RETRY_DELAY_SECONDS) + + # Add a randomness / jitter to the retry delay to avoid overwhelming the server with retries. + timeout = retry_delay * (1 - 0.25 * random()) + return timeout if timeout >= 0 else 0 + + +def _should_retry(response: httpx.Response) -> bool: + retriable_400s = [429, 408, 409] + return response.status_code >= 500 or response.status_code in retriable_400s + + +def remove_omit_from_dict( + original: typing.Dict[str, typing.Optional[typing.Any]], omit: typing.Optional[typing.Any] +) -> typing.Dict[str, typing.Any]: + if omit is None: + return original + new: typing.Dict[str, typing.Any] = {} + for key, value in original.items(): + if value is not omit: + new[key] = value + return new + + +def maybe_filter_request_body( + data: typing.Optional[typing.Any], + request_options: typing.Optional[RequestOptions], + omit: typing.Optional[typing.Any], +) -> typing.Optional[typing.Any]: + if data is None: + return ( + jsonable_encoder(request_options.get("additional_body_parameters", {})) + if request_options is not None + else None + ) + elif not isinstance(data, typing.Mapping): + data_content = jsonable_encoder(data) + else: + data_content = { + **(jsonable_encoder(remove_omit_from_dict(data, omit))), # type: ignore + **( + jsonable_encoder(request_options.get("additional_body_parameters", {})) + if request_options is not None + else {} + ), + } + return data_content + + +# Abstracted out for testing purposes +def get_request_body( + *, + json: typing.Optional[typing.Any], + data: typing.Optional[typing.Any], + request_options: typing.Optional[RequestOptions], + omit: typing.Optional[typing.Any], +) -> typing.Tuple[typing.Optional[typing.Any], typing.Optional[typing.Any]]: + json_body = None + data_body = None + if data is not None: + data_body = maybe_filter_request_body(data, request_options, omit) + else: + # If both data and json are None, we send json data in the event extra properties are specified + json_body = maybe_filter_request_body(json, request_options, omit) + + return json_body, data_body + + +class HttpClient: + def __init__( + self, + *, + httpx_client: httpx.Client, + base_timeout: typing.Optional[float], + base_headers: typing.Dict[str, str], + base_url: typing.Optional[str] = None, + ): + self.base_url = base_url + self.base_timeout = base_timeout + self.base_headers = base_headers + self.httpx_client = httpx_client + + def get_base_url(self, maybe_base_url: typing.Optional[str]) -> str: + base_url = self.base_url if maybe_base_url is None else maybe_base_url + if base_url is None: + raise ValueError("A base_url is required to make this request, please provide one and try again.") + return base_url + + def request( + self, + path: typing.Optional[str] = None, + *, + method: str, + base_url: typing.Optional[str] = None, + params: typing.Optional[typing.Dict[str, typing.Any]] = None, + json: typing.Optional[typing.Any] = None, + data: typing.Optional[typing.Any] = None, + content: typing.Optional[typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]]] = None, + files: typing.Optional[typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]]] = None, + headers: typing.Optional[typing.Dict[str, typing.Any]] = None, + request_options: typing.Optional[RequestOptions] = None, + retries: int = 0, + omit: typing.Optional[typing.Any] = None, + ) -> httpx.Response: + base_url = self.get_base_url(base_url) + timeout = ( + request_options.get("timeout_in_seconds") + if request_options is not None and request_options.get("timeout_in_seconds") is not None + else self.base_timeout + ) + + json_body, data_body = get_request_body(json=json, data=data, request_options=request_options, omit=omit) + + response = self.httpx_client.request( + method=method, + url=urllib.parse.urljoin(f"{base_url}/", path), + headers=jsonable_encoder( + remove_none_from_dict( + { + **self.base_headers, + **(headers if headers is not None else {}), + **(request_options.get("additional_headers", {}) if request_options is not None else {}), + } + ) + ), + params=encode_query( + jsonable_encoder( + remove_none_from_dict( + remove_omit_from_dict( + { + **(params if params is not None else {}), + **( + request_options.get("additional_query_parameters", {}) + if request_options is not None + else {} + ), + }, + omit, + ) + ) + ) + ), + json=json_body, + data=data_body, + content=content, + files=convert_file_dict_to_httpx_tuples(remove_none_from_dict(files)) if files is not None else None, + timeout=timeout, + ) + + max_retries: int = request_options.get("max_retries", 0) if request_options is not None else 0 + if _should_retry(response=response): + if max_retries > retries: + time.sleep(_retry_timeout(response=response, retries=retries)) + return self.request( + path=path, + method=method, + base_url=base_url, + params=params, + json=json, + content=content, + files=files, + headers=headers, + request_options=request_options, + retries=retries + 1, + omit=omit, + ) + + return response + + @contextmanager + def stream( + self, + path: typing.Optional[str] = None, + *, + method: str, + base_url: typing.Optional[str] = None, + params: typing.Optional[typing.Dict[str, typing.Any]] = None, + json: typing.Optional[typing.Any] = None, + data: typing.Optional[typing.Any] = None, + content: typing.Optional[typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]]] = None, + files: typing.Optional[typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]]] = None, + headers: typing.Optional[typing.Dict[str, typing.Any]] = None, + request_options: typing.Optional[RequestOptions] = None, + retries: int = 0, + omit: typing.Optional[typing.Any] = None, + ) -> typing.Iterator[httpx.Response]: + base_url = self.get_base_url(base_url) + timeout = ( + request_options.get("timeout_in_seconds") + if request_options is not None and request_options.get("timeout_in_seconds") is not None + else self.base_timeout + ) + + json_body, data_body = get_request_body(json=json, data=data, request_options=request_options, omit=omit) + + with self.httpx_client.stream( + method=method, + url=urllib.parse.urljoin(f"{base_url}/", path), + headers=jsonable_encoder( + remove_none_from_dict( + { + **self.base_headers, + **(headers if headers is not None else {}), + **(request_options.get("additional_headers", {}) if request_options is not None else {}), + } + ) + ), + params=encode_query( + jsonable_encoder( + remove_none_from_dict( + remove_omit_from_dict( + { + **(params if params is not None else {}), + **( + request_options.get("additional_query_parameters", {}) + if request_options is not None + else {} + ), + }, + omit, + ) + ) + ) + ), + json=json_body, + data=data_body, + content=content, + files=convert_file_dict_to_httpx_tuples(remove_none_from_dict(files)) if files is not None else None, + timeout=timeout, + ) as stream: + yield stream + + +class AsyncHttpClient: + def __init__( + self, + *, + httpx_client: httpx.AsyncClient, + base_timeout: typing.Optional[float], + base_headers: typing.Dict[str, str], + base_url: typing.Optional[str] = None, + ): + self.base_url = base_url + self.base_timeout = base_timeout + self.base_headers = base_headers + self.httpx_client = httpx_client + + def get_base_url(self, maybe_base_url: typing.Optional[str]) -> str: + base_url = self.base_url if maybe_base_url is None else maybe_base_url + if base_url is None: + raise ValueError("A base_url is required to make this request, please provide one and try again.") + return base_url + + async def request( + self, + path: typing.Optional[str] = None, + *, + method: str, + base_url: typing.Optional[str] = None, + params: typing.Optional[typing.Dict[str, typing.Any]] = None, + json: typing.Optional[typing.Any] = None, + data: typing.Optional[typing.Any] = None, + content: typing.Optional[typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]]] = None, + files: typing.Optional[typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]]] = None, + headers: typing.Optional[typing.Dict[str, typing.Any]] = None, + request_options: typing.Optional[RequestOptions] = None, + retries: int = 0, + omit: typing.Optional[typing.Any] = None, + ) -> httpx.Response: + base_url = self.get_base_url(base_url) + timeout = ( + request_options.get("timeout_in_seconds") + if request_options is not None and request_options.get("timeout_in_seconds") is not None + else self.base_timeout + ) + + json_body, data_body = get_request_body(json=json, data=data, request_options=request_options, omit=omit) + + # Add the input to each of these and do None-safety checks + response = await self.httpx_client.request( + method=method, + url=urllib.parse.urljoin(f"{base_url}/", path), + headers=jsonable_encoder( + remove_none_from_dict( + { + **self.base_headers, + **(headers if headers is not None else {}), + **(request_options.get("additional_headers", {}) if request_options is not None else {}), + } + ) + ), + params=encode_query( + jsonable_encoder( + remove_none_from_dict( + remove_omit_from_dict( + { + **(params if params is not None else {}), + **( + request_options.get("additional_query_parameters", {}) + if request_options is not None + else {} + ), + }, + omit, + ) + ) + ) + ), + json=json_body, + data=data_body, + content=content, + files=convert_file_dict_to_httpx_tuples(remove_none_from_dict(files)) if files is not None else None, + timeout=timeout, + ) + + max_retries: int = request_options.get("max_retries", 0) if request_options is not None else 0 + if _should_retry(response=response): + if max_retries > retries: + await asyncio.sleep(_retry_timeout(response=response, retries=retries)) + return await self.request( + path=path, + method=method, + base_url=base_url, + params=params, + json=json, + content=content, + files=files, + headers=headers, + request_options=request_options, + retries=retries + 1, + omit=omit, + ) + return response + + @asynccontextmanager + async def stream( + self, + path: typing.Optional[str] = None, + *, + method: str, + base_url: typing.Optional[str] = None, + params: typing.Optional[typing.Dict[str, typing.Any]] = None, + json: typing.Optional[typing.Any] = None, + data: typing.Optional[typing.Any] = None, + content: typing.Optional[typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]]] = None, + files: typing.Optional[typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]]] = None, + headers: typing.Optional[typing.Dict[str, typing.Any]] = None, + request_options: typing.Optional[RequestOptions] = None, + retries: int = 0, + omit: typing.Optional[typing.Any] = None, + ) -> typing.AsyncIterator[httpx.Response]: + base_url = self.get_base_url(base_url) + timeout = ( + request_options.get("timeout_in_seconds") + if request_options is not None and request_options.get("timeout_in_seconds") is not None + else self.base_timeout + ) + + json_body, data_body = get_request_body(json=json, data=data, request_options=request_options, omit=omit) + + async with self.httpx_client.stream( + method=method, + url=urllib.parse.urljoin(f"{base_url}/", path), + headers=jsonable_encoder( + remove_none_from_dict( + { + **self.base_headers, + **(headers if headers is not None else {}), + **(request_options.get("additional_headers", {}) if request_options is not None else {}), + } + ) + ), + params=encode_query( + jsonable_encoder( + remove_none_from_dict( + remove_omit_from_dict( + { + **(params if params is not None else {}), + **( + request_options.get("additional_query_parameters", {}) + if request_options is not None + else {} + ), + }, + omit=omit, + ) + ) + ) + ), + json=json_body, + data=data_body, + content=content, + files=convert_file_dict_to_httpx_tuples(remove_none_from_dict(files)) if files is not None else None, + timeout=timeout, + ) as stream: + yield stream diff --git a/src/webflow/core/jsonable_encoder.py b/src/webflow/core/jsonable_encoder.py index 37238ab..7f48273 100644 --- a/src/webflow/core/jsonable_encoder.py +++ b/src/webflow/core/jsonable_encoder.py @@ -16,12 +16,8 @@ from types import GeneratorType from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Union -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - from .datetime_utils import serialize_datetime +from .pydantic_utilities import pydantic_v1 SetIntStr = Set[Union[int, str]] DictIntStrAny = Dict[Union[int, str], Any] @@ -36,7 +32,7 @@ def generate_encoders_by_class_tuples( return encoders_by_class_tuples -encoders_by_class_tuples = generate_encoders_by_class_tuples(pydantic.json.ENCODERS_BY_TYPE) +encoders_by_class_tuples = generate_encoders_by_class_tuples(pydantic_v1.json.ENCODERS_BY_TYPE) def jsonable_encoder(obj: Any, custom_encoder: Optional[Dict[Any, Callable[[Any], Any]]] = None) -> Any: @@ -48,7 +44,7 @@ def jsonable_encoder(obj: Any, custom_encoder: Optional[Dict[Any, Callable[[Any] for encoder_type, encoder_instance in custom_encoder.items(): if isinstance(obj, encoder_type): return encoder_instance(obj) - if isinstance(obj, pydantic.BaseModel): + if isinstance(obj, pydantic_v1.BaseModel): encoder = getattr(obj.__config__, "json_encoders", {}) if custom_encoder: encoder.update(custom_encoder) @@ -65,10 +61,10 @@ def jsonable_encoder(obj: Any, custom_encoder: Optional[Dict[Any, Callable[[Any] return str(obj) if isinstance(obj, (str, int, float, type(None))): return obj - if isinstance(obj, dt.date): - return str(obj) if isinstance(obj, dt.datetime): return serialize_datetime(obj) + if isinstance(obj, dt.date): + return str(obj) if isinstance(obj, dict): encoded_dict = {} allowed_keys = set(obj.keys()) @@ -84,8 +80,8 @@ def jsonable_encoder(obj: Any, custom_encoder: Optional[Dict[Any, Callable[[Any] encoded_list.append(jsonable_encoder(item, custom_encoder=custom_encoder)) return encoded_list - if type(obj) in pydantic.json.ENCODERS_BY_TYPE: - return pydantic.json.ENCODERS_BY_TYPE[type(obj)](obj) + if type(obj) in pydantic_v1.json.ENCODERS_BY_TYPE: + return pydantic_v1.json.ENCODERS_BY_TYPE[type(obj)](obj) for encoder, classes_tuple in encoders_by_class_tuples.items(): if isinstance(obj, classes_tuple): return encoder(obj) diff --git a/src/webflow/core/pydantic_utilities.py b/src/webflow/core/pydantic_utilities.py new file mode 100644 index 0000000..a72c1a5 --- /dev/null +++ b/src/webflow/core/pydantic_utilities.py @@ -0,0 +1,28 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic + +IS_PYDANTIC_V2 = pydantic.VERSION.startswith("2.") + +if IS_PYDANTIC_V2: + import pydantic.v1 as pydantic_v1 # type: ignore # nopycln: import +else: + import pydantic as pydantic_v1 # type: ignore # nopycln: import + + +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + +__all__ = ["pydantic_v1"] diff --git a/src/webflow/core/query_encoder.py b/src/webflow/core/query_encoder.py new file mode 100644 index 0000000..1f5f766 --- /dev/null +++ b/src/webflow/core/query_encoder.py @@ -0,0 +1,33 @@ +# This file was auto-generated by Fern from our API Definition. + +from collections import ChainMap +from typing import Any, Dict, Optional + +from .pydantic_utilities import pydantic_v1 + + +# Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: + result = {} + for k, v in dict_flat.items(): + key = f"{key_prefix}[{k}]" if key_prefix is not None else k + if isinstance(v, dict): + result.update(traverse_query_dict(v, key)) + else: + result[key] = v + return result + + +def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: + if isinstance(query_value, pydantic_v1.BaseModel) or isinstance(query_value, dict): + if isinstance(query_value, pydantic_v1.BaseModel): + obj_dict = query_value.dict(by_alias=True) + else: + obj_dict = query_value + return traverse_query_dict(obj_dict, query_key) + + return {query_key: query_value} + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: + return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None diff --git a/src/webflow/core/remove_none_from_dict.py b/src/webflow/core/remove_none_from_dict.py index 2da30f7..c229814 100644 --- a/src/webflow/core/remove_none_from_dict.py +++ b/src/webflow/core/remove_none_from_dict.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from typing import Any, Dict, Optional +from typing import Any, Dict, Mapping, Optional -def remove_none_from_dict(original: Dict[str, Optional[Any]]) -> Dict[str, Any]: +def remove_none_from_dict(original: Mapping[str, Optional[Any]]) -> Dict[str, Any]: new: Dict[str, Any] = {} for key, value in original.items(): if value is not None: diff --git a/src/webflow/core/request_options.py b/src/webflow/core/request_options.py index 32e86b0..d0bf0db 100644 --- a/src/webflow/core/request_options.py +++ b/src/webflow/core/request_options.py @@ -5,10 +5,10 @@ try: from typing import NotRequired # type: ignore except ImportError: - from typing_extensions import NotRequired # type: ignore + from typing_extensions import NotRequired -class RequestOptions(typing.TypedDict): +class RequestOptions(typing.TypedDict, total=False): """ Additional options for request-specific configuration when calling APIs via the SDK. This is used primarily as an optional final parameter for service functions. @@ -16,6 +16,8 @@ class RequestOptions(typing.TypedDict): Attributes: - timeout_in_seconds: int. The number of seconds to await an API call before timing out. + - max_retries: int. The max number of retries to attempt if the API call fails. + - additional_headers: typing.Dict[str, typing.Any]. A dictionary containing additional parameters to spread into the request's header dict - additional_query_parameters: typing.Dict[str, typing.Any]. A dictionary containing additional parameters to spread into the request's query parameters dict @@ -24,6 +26,7 @@ class RequestOptions(typing.TypedDict): """ timeout_in_seconds: NotRequired[int] + max_retries: NotRequired[int] additional_headers: NotRequired[typing.Dict[str, typing.Any]] additional_query_parameters: NotRequired[typing.Dict[str, typing.Any]] additional_body_parameters: NotRequired[typing.Dict[str, typing.Any]] diff --git a/src/webflow/resources/__init__.py b/src/webflow/resources/__init__.py index b2501ad..91d1d63 100644 --- a/src/webflow/resources/__init__.py +++ b/src/webflow/resources/__init__.py @@ -18,41 +18,19 @@ ) from .access_groups import AccessGroupsListRequestSort from .inventory import InventoryUpdateRequestInventoryType -from .orders import OrdersRefundRequestReason -from .pages import DomWriteNodesItem -from .products import ( - ProductSkuCreateProduct, - ProductSkuCreateProductFieldData, - ProductSkuCreateProductFieldDataEcProductType, - ProductSkuCreateProductFieldDataTaxCategory, - ProductSkuCreateSku, - ProductSkuCreateSkuFieldData, - ProductSkuCreateSkuFieldDataCompareAtPrice, - ProductSkuCreateSkuFieldDataEcSkuBillingMethod, - ProductSkuCreateSkuFieldDataEcSkuSubscriptionPlan, - ProductSkuCreateSkuFieldDataEcSkuSubscriptionPlanInterval, - ProductSkuCreateSkuFieldDataPrice, - ProductsCreateSkuResponse, -) +from .orders import OrdersListRequestStatus, OrdersRefundRequestReason +from .pages import DomWriteNodesItem, UpdateStaticContentResponse +from .products import ProductsCreateSkuResponse from .users import UsersListRequestSort, UsersUpdateRequestData __all__ = [ "AccessGroupsListRequestSort", "DomWriteNodesItem", "InventoryUpdateRequestInventoryType", + "OrdersListRequestStatus", "OrdersRefundRequestReason", - "ProductSkuCreateProduct", - "ProductSkuCreateProductFieldData", - "ProductSkuCreateProductFieldDataEcProductType", - "ProductSkuCreateProductFieldDataTaxCategory", - "ProductSkuCreateSku", - "ProductSkuCreateSkuFieldData", - "ProductSkuCreateSkuFieldDataCompareAtPrice", - "ProductSkuCreateSkuFieldDataEcSkuBillingMethod", - "ProductSkuCreateSkuFieldDataEcSkuSubscriptionPlan", - "ProductSkuCreateSkuFieldDataEcSkuSubscriptionPlanInterval", - "ProductSkuCreateSkuFieldDataPrice", "ProductsCreateSkuResponse", + "UpdateStaticContentResponse", "UsersListRequestSort", "UsersUpdateRequestData", "access_groups", diff --git a/src/webflow/resources/access_groups/client.py b/src/webflow/resources/access_groups/client.py index bfd306e..2f0e14f 100644 --- a/src/webflow/resources/access_groups/client.py +++ b/src/webflow/resources/access_groups/client.py @@ -1,13 +1,12 @@ # This file was auto-generated by Fern from our API Definition. import typing -import urllib.parse from json.decoder import JSONDecodeError from ...core.api_error import ApiError from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ...core.jsonable_encoder import jsonable_encoder -from ...core.remove_none_from_dict import remove_none_from_dict +from ...core.pydantic_utilities import pydantic_v1 from ...core.request_options import RequestOptions from ...errors.bad_request_error import BadRequestError from ...errors.forbidden_error import ForbiddenError @@ -18,11 +17,6 @@ from ...types.access_group_list import AccessGroupList from .types.access_groups_list_request_sort import AccessGroupsListRequestSort -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - class AccessGroupsClient: def __init__(self, *, client_wrapper: SyncClientWrapper): @@ -40,17 +34,31 @@ def list( """ Get a list of access groups for a site

Required scope | `users:read` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site + + offset : typing.Optional[float] + Offset used for pagination if the results have more than limit records + + limit : typing.Optional[float] + Maximum number of records to be returned (max limit: 100) + + sort : typing.Optional[AccessGroupsListRequestSort] + Sort string to use when ordering access groups + Can be prefixed with a `-` to reverse the sort (ex. `-CreatedOn`) - - offset: typing.Optional[float]. Offset used for pagination if the results have more than limit records + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - limit: typing.Optional[float]. Maximum number of records to be returned (max limit: 100) + Returns + ------- + AccessGroupList + Request was successful - - sort: typing.Optional[AccessGroupsListRequestSort]. Sort string to use when ordering access groups - Can be prefixed with a `-` to reverse the sort (ex. `-CreatedOn`) - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -61,51 +69,26 @@ def list( ) """ _response = self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/accessgroups" - ), - params=jsonable_encoder( - remove_none_from_dict( - { - "offset": offset, - "limit": limit, - "sort": sort, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/accessgroups", + method="GET", + params={"offset": offset, "limit": limit, "sort": sort}, + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(AccessGroupList, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(AccessGroupList, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -128,17 +111,31 @@ async def list( """ Get a list of access groups for a site

Required scope | `users:read` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site + + offset : typing.Optional[float] + Offset used for pagination if the results have more than limit records + + limit : typing.Optional[float] + Maximum number of records to be returned (max limit: 100) + + sort : typing.Optional[AccessGroupsListRequestSort] + Sort string to use when ordering access groups + Can be prefixed with a `-` to reverse the sort (ex. `-CreatedOn`) - - offset: typing.Optional[float]. Offset used for pagination if the results have more than limit records + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - limit: typing.Optional[float]. Maximum number of records to be returned (max limit: 100) + Returns + ------- + AccessGroupList + Request was successful - - sort: typing.Optional[AccessGroupsListRequestSort]. Sort string to use when ordering access groups - Can be prefixed with a `-` to reverse the sort (ex. `-CreatedOn`) - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -149,51 +146,26 @@ async def list( ) """ _response = await self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/accessgroups" - ), - params=jsonable_encoder( - remove_none_from_dict( - { - "offset": offset, - "limit": limit, - "sort": sort, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/accessgroups", + method="GET", + params={"offset": offset, "limit": limit, "sort": sort}, + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(AccessGroupList, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(AccessGroupList, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/src/webflow/resources/assets/client.py b/src/webflow/resources/assets/client.py index 7be5754..131d573 100644 --- a/src/webflow/resources/assets/client.py +++ b/src/webflow/resources/assets/client.py @@ -1,13 +1,12 @@ # This file was auto-generated by Fern from our API Definition. import typing -import urllib.parse from json.decoder import JSONDecodeError from ...core.api_error import ApiError from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ...core.jsonable_encoder import jsonable_encoder -from ...core.remove_none_from_dict import remove_none_from_dict +from ...core.pydantic_utilities import pydantic_v1 from ...core.request_options import RequestOptions from ...errors.bad_request_error import BadRequestError from ...errors.internal_server_error import InternalServerError @@ -20,11 +19,6 @@ from ...types.asset_upload import AssetUpload from ...types.assets import Assets -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -37,11 +31,21 @@ def list(self, site_id: str, *, request_options: typing.Optional[RequestOptions] """ List assets for a given site

Required scope | `assets:read` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + Assets + Request was successful - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -52,38 +56,21 @@ def list(self, site_id: str, *, request_options: typing.Optional[RequestOptions] ) """ _response = self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/assets" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/assets", method="GET", request_options=request_options ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Assets, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(Assets, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -101,17 +88,30 @@ def create( """ Create a new asset entry.

This endpoint generates a response with the following information: `uploadUrl` and `uploadDetails`. You can use these two properties to [upload the file to Amazon s3 by making a POST](https://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectPOST.html) request to the `uploadUrl` with the `uploadDetails` object as your header information in the request.

Required scope | `assets:write` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site + + file_name : str + file name including file extension + + file_hash : str + MD5 hash of the file - - file_name: str. file name including file extension + parent_folder : typing.Optional[str] + id of the Asset folder (optional) - - file_hash: str. MD5 hash of the file + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - parent_folder: typing.Optional[str]. id of the Asset folder (optional) + Returns + ------- + AssetUpload + Request was successful - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -121,51 +121,28 @@ def create( site_id="site_id", file_name="file.png", file_hash="3c7d87c9575702bc3b1e991f4d3c638e", - parent_folder="6436b1ce5281cace05b65aea", ) """ - _request: typing.Dict[str, typing.Any] = {"fileName": file_name, "fileHash": file_hash} - if parent_folder is not OMIT: - _request["parentFolder"] = parent_folder _response = self._client_wrapper.httpx_client.request( - "POST", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/assets" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/assets", + method="POST", + json={"fileName": file_name, "fileHash": file_hash, "parentFolder": parent_folder}, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(AssetUpload, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(AssetUpload, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -175,11 +152,21 @@ def get(self, asset_id: str, *, request_options: typing.Optional[RequestOptions] """ Get an Asset

Required scope | `assets:read` - Parameters: - - asset_id: str. Unique identifier for an Asset on a site + Parameters + ---------- + asset_id : str + Unique identifier for an Asset on a site - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + Asset + Request was successful + + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -190,36 +177,21 @@ def get(self, asset_id: str, *, request_options: typing.Optional[RequestOptions] ) """ _response = self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"assets/{jsonable_encoder(asset_id)}"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"assets/{jsonable_encoder(asset_id)}", method="GET", request_options=request_options ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Asset, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(Asset, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -229,11 +201,20 @@ def delete(self, asset_id: str, *, request_options: typing.Optional[RequestOptio """ Delete an Asset - Parameters: - - asset_id: str. Unique identifier for an Asset on a site + Parameters + ---------- + asset_id : str + Unique identifier for an Asset on a site + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + None - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -244,36 +225,21 @@ def delete(self, asset_id: str, *, request_options: typing.Optional[RequestOptio ) """ _response = self._client_wrapper.httpx_client.request( - "DELETE", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"assets/{jsonable_encoder(asset_id)}"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"assets/{jsonable_encoder(asset_id)}", method="DELETE", request_options=request_options ) - if 200 <= _response.status_code < 300: - return - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -285,13 +251,24 @@ def update( """ Update an Asset

Required scope | `assets:write` - Parameters: - - asset_id: str. Unique identifier for an Asset on a site + Parameters + ---------- + asset_id : str + Unique identifier for an Asset on a site - - display_name: str. file name including file extension + display_name : str + file name including file extension - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + Asset + Request was successful + + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -303,42 +280,25 @@ def update( ) """ _response = self._client_wrapper.httpx_client.request( - "PATCH", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"assets/{jsonable_encoder(asset_id)}"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder({"displayName": display_name}) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder({"displayName": display_name}), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"assets/{jsonable_encoder(asset_id)}", + method="PATCH", + json={"displayName": display_name}, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Asset, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(Asset, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -348,11 +308,21 @@ def list_folders(self, site_id: str, *, request_options: typing.Optional[Request """ List Asset Folders within a given site

Required scope | `assets:read` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AssetFolderList + Request was successful - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -363,38 +333,21 @@ def list_folders(self, site_id: str, *, request_options: typing.Optional[Request ) """ _response = self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/asset_folders" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/asset_folders", method="GET", request_options=request_options ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(AssetFolderList, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(AssetFolderList, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -411,15 +364,27 @@ def create_folder( """ Create an Asset Folder within a given site

Required scope | `assets:write` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site - - display_name: str. A human readable name for the Asset Folder + display_name : str + A human readable name for the Asset Folder - - parent_folder: typing.Optional[str]. An (optional) pointer to a parent Asset Folder (or null for root) + parent_folder : typing.Optional[str] + An (optional) pointer to a parent Asset Folder (or null for root) - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AssetFolder + Request was successful + + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -428,51 +393,28 @@ def create_folder( client.assets.create_folder( site_id="site_id", display_name="my asset folder", - parent_folder="6390c49774a71f99f21a08eb", ) """ - _request: typing.Dict[str, typing.Any] = {"displayName": display_name} - if parent_folder is not OMIT: - _request["parentFolder"] = parent_folder _response = self._client_wrapper.httpx_client.request( - "POST", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/asset_folders" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/asset_folders", + method="POST", + json={"displayName": display_name, "parentFolder": parent_folder}, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(AssetFolder, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(AssetFolder, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -484,11 +426,21 @@ def get_folder( """ Get details about a specific Asset Folder

Required scope | `assets:read` - Parameters: - - asset_folder_id: str. Unique identifier for an Asset Folder + Parameters + ---------- + asset_folder_id : str + Unique identifier for an Asset Folder + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AssetFolder + Request was successful - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -499,38 +451,21 @@ def get_folder( ) """ _response = self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"asset_folders/{jsonable_encoder(asset_folder_id)}" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"asset_folders/{jsonable_encoder(asset_folder_id)}", method="GET", request_options=request_options ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(AssetFolder, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(AssetFolder, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -545,11 +480,21 @@ async def list(self, site_id: str, *, request_options: typing.Optional[RequestOp """ List assets for a given site

Required scope | `assets:read` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + Assets + Request was successful + + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -560,38 +505,21 @@ async def list(self, site_id: str, *, request_options: typing.Optional[RequestOp ) """ _response = await self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/assets" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/assets", method="GET", request_options=request_options ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Assets, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(Assets, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -609,17 +537,30 @@ async def create( """ Create a new asset entry.

This endpoint generates a response with the following information: `uploadUrl` and `uploadDetails`. You can use these two properties to [upload the file to Amazon s3 by making a POST](https://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectPOST.html) request to the `uploadUrl` with the `uploadDetails` object as your header information in the request.

Required scope | `assets:write` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site + + file_name : str + file name including file extension + + file_hash : str + MD5 hash of the file - - file_name: str. file name including file extension + parent_folder : typing.Optional[str] + id of the Asset folder (optional) - - file_hash: str. MD5 hash of the file + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - parent_folder: typing.Optional[str]. id of the Asset folder (optional) + Returns + ------- + AssetUpload + Request was successful - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -629,51 +570,28 @@ async def create( site_id="site_id", file_name="file.png", file_hash="3c7d87c9575702bc3b1e991f4d3c638e", - parent_folder="6436b1ce5281cace05b65aea", ) """ - _request: typing.Dict[str, typing.Any] = {"fileName": file_name, "fileHash": file_hash} - if parent_folder is not OMIT: - _request["parentFolder"] = parent_folder _response = await self._client_wrapper.httpx_client.request( - "POST", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/assets" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/assets", + method="POST", + json={"fileName": file_name, "fileHash": file_hash, "parentFolder": parent_folder}, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(AssetUpload, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(AssetUpload, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -683,11 +601,21 @@ async def get(self, asset_id: str, *, request_options: typing.Optional[RequestOp """ Get an Asset

Required scope | `assets:read` - Parameters: - - asset_id: str. Unique identifier for an Asset on a site + Parameters + ---------- + asset_id : str + Unique identifier for an Asset on a site - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + Asset + Request was successful + + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -698,36 +626,21 @@ async def get(self, asset_id: str, *, request_options: typing.Optional[RequestOp ) """ _response = await self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"assets/{jsonable_encoder(asset_id)}"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"assets/{jsonable_encoder(asset_id)}", method="GET", request_options=request_options ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Asset, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(Asset, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -737,11 +650,20 @@ async def delete(self, asset_id: str, *, request_options: typing.Optional[Reques """ Delete an Asset - Parameters: - - asset_id: str. Unique identifier for an Asset on a site + Parameters + ---------- + asset_id : str + Unique identifier for an Asset on a site + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + None - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -752,36 +674,21 @@ async def delete(self, asset_id: str, *, request_options: typing.Optional[Reques ) """ _response = await self._client_wrapper.httpx_client.request( - "DELETE", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"assets/{jsonable_encoder(asset_id)}"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"assets/{jsonable_encoder(asset_id)}", method="DELETE", request_options=request_options ) - if 200 <= _response.status_code < 300: - return - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -793,13 +700,24 @@ async def update( """ Update an Asset

Required scope | `assets:write` - Parameters: - - asset_id: str. Unique identifier for an Asset on a site + Parameters + ---------- + asset_id : str + Unique identifier for an Asset on a site - - display_name: str. file name including file extension + display_name : str + file name including file extension - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + Asset + Request was successful + + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -811,42 +729,25 @@ async def update( ) """ _response = await self._client_wrapper.httpx_client.request( - "PATCH", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"assets/{jsonable_encoder(asset_id)}"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder({"displayName": display_name}) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder({"displayName": display_name}), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"assets/{jsonable_encoder(asset_id)}", + method="PATCH", + json={"displayName": display_name}, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Asset, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(Asset, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -858,11 +759,21 @@ async def list_folders( """ List Asset Folders within a given site

Required scope | `assets:read` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AssetFolderList + Request was successful - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -873,38 +784,21 @@ async def list_folders( ) """ _response = await self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/asset_folders" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/asset_folders", method="GET", request_options=request_options ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(AssetFolderList, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(AssetFolderList, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -921,15 +815,27 @@ async def create_folder( """ Create an Asset Folder within a given site

Required scope | `assets:write` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site - - display_name: str. A human readable name for the Asset Folder + display_name : str + A human readable name for the Asset Folder - - parent_folder: typing.Optional[str]. An (optional) pointer to a parent Asset Folder (or null for root) + parent_folder : typing.Optional[str] + An (optional) pointer to a parent Asset Folder (or null for root) - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AssetFolder + Request was successful + + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -938,51 +844,28 @@ async def create_folder( await client.assets.create_folder( site_id="site_id", display_name="my asset folder", - parent_folder="6390c49774a71f99f21a08eb", ) """ - _request: typing.Dict[str, typing.Any] = {"displayName": display_name} - if parent_folder is not OMIT: - _request["parentFolder"] = parent_folder _response = await self._client_wrapper.httpx_client.request( - "POST", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/asset_folders" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/asset_folders", + method="POST", + json={"displayName": display_name, "parentFolder": parent_folder}, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(AssetFolder, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(AssetFolder, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -994,11 +877,21 @@ async def get_folder( """ Get details about a specific Asset Folder

Required scope | `assets:read` - Parameters: - - asset_folder_id: str. Unique identifier for an Asset Folder + Parameters + ---------- + asset_folder_id : str + Unique identifier for an Asset Folder + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AssetFolder + Request was successful - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -1009,38 +902,21 @@ async def get_folder( ) """ _response = await self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"asset_folders/{jsonable_encoder(asset_folder_id)}" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"asset_folders/{jsonable_encoder(asset_folder_id)}", method="GET", request_options=request_options ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(AssetFolder, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(AssetFolder, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/src/webflow/resources/collections/__init__.py b/src/webflow/resources/collections/__init__.py index ea60c9c..a029bd0 100644 --- a/src/webflow/resources/collections/__init__.py +++ b/src/webflow/resources/collections/__init__.py @@ -1,5 +1,23 @@ # This file was auto-generated by Fern from our API Definition. -from .resources import BulkCollectionItemFieldData, FieldCreateType, ItemsPublishItemResponse, fields, items +from .resources import ( + BulkCollectionItemFieldData, + FieldCreateType, + ItemsListItemsLiveRequestSortBy, + ItemsListItemsLiveRequestSortOrder, + ItemsListItemsRequestSortBy, + ItemsListItemsRequestSortOrder, + fields, + items, +) -__all__ = ["BulkCollectionItemFieldData", "FieldCreateType", "ItemsPublishItemResponse", "fields", "items"] +__all__ = [ + "BulkCollectionItemFieldData", + "FieldCreateType", + "ItemsListItemsLiveRequestSortBy", + "ItemsListItemsLiveRequestSortOrder", + "ItemsListItemsRequestSortBy", + "ItemsListItemsRequestSortOrder", + "fields", + "items", +] diff --git a/src/webflow/resources/collections/client.py b/src/webflow/resources/collections/client.py index 669cb06..1d1ba20 100644 --- a/src/webflow/resources/collections/client.py +++ b/src/webflow/resources/collections/client.py @@ -1,13 +1,12 @@ # This file was auto-generated by Fern from our API Definition. import typing -import urllib.parse from json.decoder import JSONDecodeError from ...core.api_error import ApiError from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ...core.jsonable_encoder import jsonable_encoder -from ...core.remove_none_from_dict import remove_none_from_dict +from ...core.pydantic_utilities import pydantic_v1 from ...core.request_options import RequestOptions from ...errors.bad_request_error import BadRequestError from ...errors.internal_server_error import InternalServerError @@ -19,11 +18,6 @@ from .resources.fields.client import AsyncFieldsClient, FieldsClient from .resources.items.client import AsyncItemsClient, ItemsClient -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -38,11 +32,21 @@ def list(self, site_id: str, *, request_options: typing.Optional[RequestOptions] """ List of all Collections within a Site.

Required scope | `cms:read` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + CollectionList + Request was successful - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -53,38 +57,21 @@ def list(self, site_id: str, *, request_options: typing.Optional[RequestOptions] ) """ _response = self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/collections" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/collections", method="GET", request_options=request_options ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(CollectionList, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(CollectionList, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -102,17 +89,30 @@ def create( """ Create a Collection for a site.

Required scope | `cms:write` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site - - display_name: str. Name of the collection. Each collection name must be distinct. + display_name : str + Name of the collection. Each collection name must be distinct. - - singular_name: str. Singular name of each item. + singular_name : str + Singular name of each item. - - slug: typing.Optional[str]. Part of a URL that identifier + slug : typing.Optional[str] + Part of a URL that identifier - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + Collection + Request was successful + + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -125,48 +125,26 @@ def create( slug="posts", ) """ - _request: typing.Dict[str, typing.Any] = {"displayName": display_name, "singularName": singular_name} - if slug is not OMIT: - _request["slug"] = slug _response = self._client_wrapper.httpx_client.request( - "POST", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/collections" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/collections", + method="POST", + json={"displayName": display_name, "singularName": singular_name, "slug": slug}, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Collection, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(Collection, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -176,11 +154,21 @@ def get(self, collection_id: str, *, request_options: typing.Optional[RequestOpt """ Get the full details of a collection from its ID.

Required scope | `cms:read` - Parameters: - - collection_id: str. Unique identifier for a Collection + Parameters + ---------- + collection_id : str + Unique identifier for a Collection + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Returns + ------- + Collection + Request was successful + + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -191,38 +179,21 @@ def get(self, collection_id: str, *, request_options: typing.Optional[RequestOpt ) """ _response = self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"collections/{jsonable_encoder(collection_id)}" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"collections/{jsonable_encoder(collection_id)}", method="GET", request_options=request_options ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Collection, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(Collection, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -232,11 +203,20 @@ def delete_collection(self, collection_id: str, *, request_options: typing.Optio """ Delete a collection using its ID.

Required scope | `cms:write` - Parameters: - - collection_id: str. Unique identifier for a Collection + Parameters + ---------- + collection_id : str + Unique identifier for a Collection + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + None - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -247,38 +227,21 @@ def delete_collection(self, collection_id: str, *, request_options: typing.Optio ) """ _response = self._client_wrapper.httpx_client.request( - "DELETE", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"collections/{jsonable_encoder(collection_id)}" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"collections/{jsonable_encoder(collection_id)}", method="DELETE", request_options=request_options ) - if 200 <= _response.status_code < 300: - return - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -290,13 +253,23 @@ def delete( """ Delete a custom field in a collection. This endpoint does not currently support bulk deletion.

Required scope | `cms:write` - Parameters: - - collection_id: str. Unique identifier for a Collection + Parameters + ---------- + collection_id : str + Unique identifier for a Collection + + field_id : str + Unique identifier for a Field in a collection + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - field_id: str. Unique identifier for a Field in a collection + Returns + ------- + None - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -308,39 +281,23 @@ def delete( ) """ _response = self._client_wrapper.httpx_client.request( - "DELETE", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"collections/{jsonable_encoder(collection_id)}/fields/{jsonable_encoder(field_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"collections/{jsonable_encoder(collection_id)}/fields/{jsonable_encoder(field_id)}", + method="DELETE", + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -357,11 +314,21 @@ async def list(self, site_id: str, *, request_options: typing.Optional[RequestOp """ List of all Collections within a Site.

Required scope | `cms:read` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + CollectionList + Request was successful + + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -372,38 +339,21 @@ async def list(self, site_id: str, *, request_options: typing.Optional[RequestOp ) """ _response = await self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/collections" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/collections", method="GET", request_options=request_options ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(CollectionList, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(CollectionList, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -421,17 +371,30 @@ async def create( """ Create a Collection for a site.

Required scope | `cms:write` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site + + display_name : str + Name of the collection. Each collection name must be distinct. - - display_name: str. Name of the collection. Each collection name must be distinct. + singular_name : str + Singular name of each item. - - singular_name: str. Singular name of each item. + slug : typing.Optional[str] + Part of a URL that identifier - - slug: typing.Optional[str]. Part of a URL that identifier + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Returns + ------- + Collection + Request was successful + + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -444,48 +407,26 @@ async def create( slug="posts", ) """ - _request: typing.Dict[str, typing.Any] = {"displayName": display_name, "singularName": singular_name} - if slug is not OMIT: - _request["slug"] = slug _response = await self._client_wrapper.httpx_client.request( - "POST", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/collections" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/collections", + method="POST", + json={"displayName": display_name, "singularName": singular_name, "slug": slug}, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Collection, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(Collection, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -495,11 +436,21 @@ async def get(self, collection_id: str, *, request_options: typing.Optional[Requ """ Get the full details of a collection from its ID.

Required scope | `cms:read` - Parameters: - - collection_id: str. Unique identifier for a Collection + Parameters + ---------- + collection_id : str + Unique identifier for a Collection + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Returns + ------- + Collection + Request was successful + + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -510,38 +461,21 @@ async def get(self, collection_id: str, *, request_options: typing.Optional[Requ ) """ _response = await self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"collections/{jsonable_encoder(collection_id)}" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"collections/{jsonable_encoder(collection_id)}", method="GET", request_options=request_options ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Collection, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(Collection, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -553,11 +487,20 @@ async def delete_collection( """ Delete a collection using its ID.

Required scope | `cms:write` - Parameters: - - collection_id: str. Unique identifier for a Collection + Parameters + ---------- + collection_id : str + Unique identifier for a Collection + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + None - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -568,38 +511,21 @@ async def delete_collection( ) """ _response = await self._client_wrapper.httpx_client.request( - "DELETE", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"collections/{jsonable_encoder(collection_id)}" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"collections/{jsonable_encoder(collection_id)}", method="DELETE", request_options=request_options ) - if 200 <= _response.status_code < 300: - return - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -611,13 +537,23 @@ async def delete( """ Delete a custom field in a collection. This endpoint does not currently support bulk deletion.

Required scope | `cms:write` - Parameters: - - collection_id: str. Unique identifier for a Collection + Parameters + ---------- + collection_id : str + Unique identifier for a Collection + + field_id : str + Unique identifier for a Field in a collection + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - field_id: str. Unique identifier for a Field in a collection + Returns + ------- + None - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -629,39 +565,23 @@ async def delete( ) """ _response = await self._client_wrapper.httpx_client.request( - "DELETE", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"collections/{jsonable_encoder(collection_id)}/fields/{jsonable_encoder(field_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"collections/{jsonable_encoder(collection_id)}/fields/{jsonable_encoder(field_id)}", + method="DELETE", + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/src/webflow/resources/collections/resources/__init__.py b/src/webflow/resources/collections/resources/__init__.py index 5b63931..2b2d370 100644 --- a/src/webflow/resources/collections/resources/__init__.py +++ b/src/webflow/resources/collections/resources/__init__.py @@ -2,6 +2,21 @@ from . import fields, items from .fields import FieldCreateType -from .items import BulkCollectionItemFieldData, ItemsPublishItemResponse +from .items import ( + BulkCollectionItemFieldData, + ItemsListItemsLiveRequestSortBy, + ItemsListItemsLiveRequestSortOrder, + ItemsListItemsRequestSortBy, + ItemsListItemsRequestSortOrder, +) -__all__ = ["BulkCollectionItemFieldData", "FieldCreateType", "ItemsPublishItemResponse", "fields", "items"] +__all__ = [ + "BulkCollectionItemFieldData", + "FieldCreateType", + "ItemsListItemsLiveRequestSortBy", + "ItemsListItemsLiveRequestSortOrder", + "ItemsListItemsRequestSortBy", + "ItemsListItemsRequestSortOrder", + "fields", + "items", +] diff --git a/src/webflow/resources/collections/resources/fields/client.py b/src/webflow/resources/collections/resources/fields/client.py index 9622f64..710092f 100644 --- a/src/webflow/resources/collections/resources/fields/client.py +++ b/src/webflow/resources/collections/resources/fields/client.py @@ -1,13 +1,12 @@ # This file was auto-generated by Fern from our API Definition. import typing -import urllib.parse from json.decoder import JSONDecodeError from .....core.api_error import ApiError from .....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from .....core.jsonable_encoder import jsonable_encoder -from .....core.remove_none_from_dict import remove_none_from_dict +from .....core.pydantic_utilities import pydantic_v1 from .....core.request_options import RequestOptions from .....errors.bad_request_error import BadRequestError from .....errors.internal_server_error import InternalServerError @@ -17,11 +16,6 @@ from .....types.field import Field from .types.field_create_type import FieldCreateType -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -34,28 +28,42 @@ def create( self, collection_id: str, *, - is_required: typing.Optional[bool] = OMIT, type: FieldCreateType, display_name: str, + is_required: typing.Optional[bool] = OMIT, help_text: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> Field: """ Create a custom field in a collection.

Slugs must be all lowercase letters without spaces. If you pass a string with uppercase letters and/or spaces to the "Slug" property, Webflow will convert the slug to lowercase and replace spaces with "-."

Only some field types can be created through the API. This endpoint does not currently support bulk creation.

Required scope | `cms:write` - Parameters: - - collection_id: str. Unique identifier for a Collection + Parameters + ---------- + collection_id : str + Unique identifier for a Collection + + type : FieldCreateType + Choose these appropriate field type for your collection data - - is_required: typing.Optional[bool]. define whether a field is required in a collection + display_name : str + The name of a field - - type: FieldCreateType. Choose these appropriate field type for your collection data + is_required : typing.Optional[bool] + define whether a field is required in a collection - - display_name: str. The name of a field + help_text : typing.Optional[str] + Additional text to help anyone filling out this field - - help_text: typing.Optional[str]. Additional text to help anyone filling out this field + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Returns + ------- + Field + Request was successful + + Examples + -------- from webflow.client import Webflow from webflow.resources.collections import FieldCreateType @@ -70,50 +78,26 @@ def create( help_text="Add the body of your post here", ) """ - _request: typing.Dict[str, typing.Any] = {"type": type, "displayName": display_name} - if is_required is not OMIT: - _request["isRequired"] = is_required - if help_text is not OMIT: - _request["helpText"] = help_text _response = self._client_wrapper.httpx_client.request( - "POST", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"collections/{jsonable_encoder(collection_id)}/fields" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"collections/{jsonable_encoder(collection_id)}/fields", + method="POST", + json={"isRequired": is_required, "type": type, "displayName": display_name, "helpText": help_text}, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Field, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(Field, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -132,19 +116,33 @@ def update( """ Update a custom field in a collection.

Required scope | `cms:write` - Parameters: - - collection_id: str. Unique identifier for a Collection + Parameters + ---------- + collection_id : str + Unique identifier for a Collection + + field_id : str + Unique identifier for a Field in a collection + + is_required : typing.Optional[bool] + Define whether a field is required in a collection - - field_id: str. Unique identifier for a Field in a collection + display_name : typing.Optional[str] + The name of a field - - is_required: typing.Optional[bool]. Define whether a field is required in a collection + help_text : typing.Optional[str] + Additional text to help anyone filling out this field - - display_name: typing.Optional[str]. The name of a field + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - help_text: typing.Optional[str]. Additional text to help anyone filling out this field + Returns + ------- + Field + Request was successful - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -158,53 +156,26 @@ def update( help_text="Add the body of your post here", ) """ - _request: typing.Dict[str, typing.Any] = {} - if is_required is not OMIT: - _request["isRequired"] = is_required - if display_name is not OMIT: - _request["displayName"] = display_name - if help_text is not OMIT: - _request["helpText"] = help_text _response = self._client_wrapper.httpx_client.request( - "PATCH", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"collections/{jsonable_encoder(collection_id)}/fields/{jsonable_encoder(field_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"collections/{jsonable_encoder(collection_id)}/fields/{jsonable_encoder(field_id)}", + method="PATCH", + json={"isRequired": is_required, "displayName": display_name, "helpText": help_text}, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Field, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(Field, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -219,28 +190,42 @@ async def create( self, collection_id: str, *, - is_required: typing.Optional[bool] = OMIT, type: FieldCreateType, display_name: str, + is_required: typing.Optional[bool] = OMIT, help_text: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> Field: """ Create a custom field in a collection.

Slugs must be all lowercase letters without spaces. If you pass a string with uppercase letters and/or spaces to the "Slug" property, Webflow will convert the slug to lowercase and replace spaces with "-."

Only some field types can be created through the API. This endpoint does not currently support bulk creation.

Required scope | `cms:write` - Parameters: - - collection_id: str. Unique identifier for a Collection + Parameters + ---------- + collection_id : str + Unique identifier for a Collection + + type : FieldCreateType + Choose these appropriate field type for your collection data - - is_required: typing.Optional[bool]. define whether a field is required in a collection + display_name : str + The name of a field - - type: FieldCreateType. Choose these appropriate field type for your collection data + is_required : typing.Optional[bool] + define whether a field is required in a collection - - display_name: str. The name of a field + help_text : typing.Optional[str] + Additional text to help anyone filling out this field - - help_text: typing.Optional[str]. Additional text to help anyone filling out this field + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Returns + ------- + Field + Request was successful + + Examples + -------- from webflow.client import AsyncWebflow from webflow.resources.collections import FieldCreateType @@ -255,50 +240,26 @@ async def create( help_text="Add the body of your post here", ) """ - _request: typing.Dict[str, typing.Any] = {"type": type, "displayName": display_name} - if is_required is not OMIT: - _request["isRequired"] = is_required - if help_text is not OMIT: - _request["helpText"] = help_text _response = await self._client_wrapper.httpx_client.request( - "POST", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"collections/{jsonable_encoder(collection_id)}/fields" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"collections/{jsonable_encoder(collection_id)}/fields", + method="POST", + json={"isRequired": is_required, "type": type, "displayName": display_name, "helpText": help_text}, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Field, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(Field, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -317,19 +278,33 @@ async def update( """ Update a custom field in a collection.

Required scope | `cms:write` - Parameters: - - collection_id: str. Unique identifier for a Collection + Parameters + ---------- + collection_id : str + Unique identifier for a Collection + + field_id : str + Unique identifier for a Field in a collection + + is_required : typing.Optional[bool] + Define whether a field is required in a collection - - field_id: str. Unique identifier for a Field in a collection + display_name : typing.Optional[str] + The name of a field - - is_required: typing.Optional[bool]. Define whether a field is required in a collection + help_text : typing.Optional[str] + Additional text to help anyone filling out this field - - display_name: typing.Optional[str]. The name of a field + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - help_text: typing.Optional[str]. Additional text to help anyone filling out this field + Returns + ------- + Field + Request was successful - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -343,53 +318,26 @@ async def update( help_text="Add the body of your post here", ) """ - _request: typing.Dict[str, typing.Any] = {} - if is_required is not OMIT: - _request["isRequired"] = is_required - if display_name is not OMIT: - _request["displayName"] = display_name - if help_text is not OMIT: - _request["helpText"] = help_text _response = await self._client_wrapper.httpx_client.request( - "PATCH", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"collections/{jsonable_encoder(collection_id)}/fields/{jsonable_encoder(field_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"collections/{jsonable_encoder(collection_id)}/fields/{jsonable_encoder(field_id)}", + method="PATCH", + json={"isRequired": is_required, "displayName": display_name, "helpText": help_text}, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Field, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(Field, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/src/webflow/resources/collections/resources/fields/types/field_create_type.py b/src/webflow/resources/collections/resources/fields/types/field_create_type.py index db7db4a..adf2907 100644 --- a/src/webflow/resources/collections/resources/fields/types/field_create_type.py +++ b/src/webflow/resources/collections/resources/fields/types/field_create_type.py @@ -21,7 +21,7 @@ class FieldCreateType(str, enum.Enum): PHONE = "Phone" NUMBER = "Number" DATE_TIME = "DateTime" - BOOLEAN = "Boolean" + SWITCH = "Switch" COLOR = "Color" FILE = "File" @@ -37,7 +37,7 @@ def visit( phone: typing.Callable[[], T_Result], number: typing.Callable[[], T_Result], date_time: typing.Callable[[], T_Result], - boolean: typing.Callable[[], T_Result], + switch: typing.Callable[[], T_Result], color: typing.Callable[[], T_Result], file: typing.Callable[[], T_Result], ) -> T_Result: @@ -61,8 +61,8 @@ def visit( return number() if self is FieldCreateType.DATE_TIME: return date_time() - if self is FieldCreateType.BOOLEAN: - return boolean() + if self is FieldCreateType.SWITCH: + return switch() if self is FieldCreateType.COLOR: return color() if self is FieldCreateType.FILE: diff --git a/src/webflow/resources/collections/resources/items/__init__.py b/src/webflow/resources/collections/resources/items/__init__.py index f9fc28c..c8549f0 100644 --- a/src/webflow/resources/collections/resources/items/__init__.py +++ b/src/webflow/resources/collections/resources/items/__init__.py @@ -1,5 +1,17 @@ # This file was auto-generated by Fern from our API Definition. -from .types import BulkCollectionItemFieldData, ItemsPublishItemResponse +from .types import ( + BulkCollectionItemFieldData, + ItemsListItemsLiveRequestSortBy, + ItemsListItemsLiveRequestSortOrder, + ItemsListItemsRequestSortBy, + ItemsListItemsRequestSortOrder, +) -__all__ = ["BulkCollectionItemFieldData", "ItemsPublishItemResponse"] +__all__ = [ + "BulkCollectionItemFieldData", + "ItemsListItemsLiveRequestSortBy", + "ItemsListItemsLiveRequestSortOrder", + "ItemsListItemsRequestSortBy", + "ItemsListItemsRequestSortOrder", +] diff --git a/src/webflow/resources/collections/resources/items/client.py b/src/webflow/resources/collections/resources/items/client.py index 21e4df3..9a51804 100644 --- a/src/webflow/resources/collections/resources/items/client.py +++ b/src/webflow/resources/collections/resources/items/client.py @@ -1,13 +1,12 @@ # This file was auto-generated by Fern from our API Definition. import typing -import urllib.parse from json.decoder import JSONDecodeError from .....core.api_error import ApiError from .....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from .....core.jsonable_encoder import jsonable_encoder -from .....core.remove_none_from_dict import remove_none_from_dict +from .....core.pydantic_utilities import pydantic_v1 from .....core.request_options import RequestOptions from .....errors.bad_request_error import BadRequestError from .....errors.internal_server_error import InternalServerError @@ -15,14 +14,13 @@ from .....errors.too_many_requests_error import TooManyRequestsError from .....errors.unauthorized_error import UnauthorizedError from .....types.collection_item import CollectionItem +from .....types.collection_item_field_data import CollectionItemFieldData from .....types.collection_item_list import CollectionItemList from .types.bulk_collection_item_field_data import BulkCollectionItemFieldData -from .types.items_publish_item_response import ItemsPublishItemResponse - -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore +from .types.items_list_items_live_request_sort_by import ItemsListItemsLiveRequestSortBy +from .types.items_list_items_live_request_sort_order import ItemsListItemsLiveRequestSortOrder +from .types.items_list_items_request_sort_by import ItemsListItemsRequestSortBy +from .types.items_list_items_request_sort_order import ItemsListItemsRequestSortOrder # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -36,25 +34,54 @@ def list_items( self, collection_id: str, *, - cms_locale_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, + cms_locale_id: typing.Optional[str] = None, offset: typing.Optional[float] = None, limit: typing.Optional[float] = None, + name: typing.Optional[str] = None, + slug: typing.Optional[str] = None, + sort_by: typing.Optional[ItemsListItemsRequestSortBy] = None, + sort_order: typing.Optional[ItemsListItemsRequestSortOrder] = None, request_options: typing.Optional[RequestOptions] = None, ) -> CollectionItemList: """ List of all Items within a Collection.

Required scope | `CMS:read` - Parameters: - - collection_id: str. Unique identifier for a Collection + Parameters + ---------- + collection_id : str + Unique identifier for a Collection + + cms_locale_id : typing.Optional[str] + Unique identifier for a CMS Locale. This UID is different from the Site locale identifier and is listed as `cmsLocaleId` in the Sites response. To query multiple locales, input a comma separated string. + + offset : typing.Optional[float] + Offset used for pagination if the results have more than limit records + + limit : typing.Optional[float] + Maximum number of records to be returned (max limit: 100) + + name : typing.Optional[str] + The name of the item(s) + + slug : typing.Optional[str] + The slug of the item - - cms_locale_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]]. Unique identifiers for CMS Locales. These UIDs are different from the Site locale identifier and are listed as `cmsLocaleId` in the Sites response. Applicable when using localization. + sort_by : typing.Optional[ItemsListItemsRequestSortBy] + Sort results by the provided value - - offset: typing.Optional[float]. Offset used for pagination if the results have more than limit records + sort_order : typing.Optional[ItemsListItemsRequestSortOrder] + Sorts the results by asc or desc - - limit: typing.Optional[float]. Maximum number of records to be returned (max limit: 100) + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Returns + ------- + CollectionItemList + Request was successful + + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -65,68 +92,92 @@ def list_items( ) """ _response = self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"collections/{jsonable_encoder(collection_id)}/items" - ), - params=jsonable_encoder( - remove_none_from_dict( - { - "cmsLocaleIds": cms_locale_ids, - "offset": offset, - "limit": limit, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, - ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(CollectionItemList, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore + f"collections/{jsonable_encoder(collection_id)}/items", + method="GET", + params={ + "cmsLocaleId": cms_locale_id, + "offset": offset, + "limit": limit, + "name": name, + "slug": slug, + "sortBy": sort_by, + "sortOrder": sort_order, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(CollectionItemList, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) def create_item( - self, collection_id: str, *, request: CollectionItem, request_options: typing.Optional[RequestOptions] = None + self, + collection_id: str, + *, + id: str, + cms_locale_id: typing.Optional[str] = OMIT, + last_published: typing.Optional[str] = OMIT, + last_updated: typing.Optional[str] = OMIT, + created_on: typing.Optional[str] = OMIT, + is_archived: typing.Optional[bool] = OMIT, + is_draft: typing.Optional[bool] = OMIT, + field_data: typing.Optional[CollectionItemFieldData] = OMIT, + request_options: typing.Optional[RequestOptions] = None, ) -> None: """ Create Item in a Collection.

To create items across multiple locales, please use this endpoint.

Required scope | `CMS:write` - Parameters: - - collection_id: str. Unique identifier for a Collection + Parameters + ---------- + collection_id : str + Unique identifier for a Collection + + id : str + Unique identifier for the Item + + cms_locale_id : typing.Optional[str] + Identifier for the locale of the CMS item + + last_published : typing.Optional[str] + The date the item was last published - - request: CollectionItem. + last_updated : typing.Optional[str] + The date the item was last updated - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- - from webflow import CollectionItem, CollectionItemFieldData + created_on : typing.Optional[str] + The date the item was created + + is_archived : typing.Optional[bool] + Boolean determining if the Item is set to archived + + is_draft : typing.Optional[bool] + Boolean determining if the Item is set to draft + + field_data : typing.Optional[CollectionItemFieldData] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + None + + Examples + -------- + from webflow import CollectionItemFieldData from webflow.client import Webflow client = Webflow( @@ -134,79 +185,201 @@ def create_item( ) client.collections.items.create_item( collection_id="collection_id", - request=CollectionItem( - id="42b720ef280c7a7a3be8cabe", - cms_locale_id="653ad57de882f528b32e810e", - last_published="2022-11-29T16:22:43.159Z", - last_updated="2022-11-17T17:19:43.282Z", - created_on="2022-11-17T17:11:57.148Z", - is_archived=False, - is_draft=False, - field_data=CollectionItemFieldData( - name="Pan Galactic Gargle Blaster Recipe", - slug="pan-galactic-gargle-blaster", - ), + id="42b720ef280c7a7a3be8cabe", + cms_locale_id="653ad57de882f528b32e810e", + last_published="2022-11-29T16:22:43.159Z", + last_updated="2022-11-17T17:19:43.282Z", + created_on="2022-11-17T17:11:57.148Z", + is_archived=False, + is_draft=False, + field_data=CollectionItemFieldData( + name="Pan Galactic Gargle Blaster Recipe", + slug="pan-galactic-gargle-blaster", ), ) """ _response = self._client_wrapper.httpx_client.request( - "POST", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"collections/{jsonable_encoder(collection_id)}/items" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + f"collections/{jsonable_encoder(collection_id)}/items", + method="POST", + json={ + "id": id, + "cmsLocaleId": cms_locale_id, + "lastPublished": last_published, + "lastUpdated": last_updated, + "createdOn": created_on, + "isArchived": is_archived, + "isDraft": is_draft, + "fieldData": field_data, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, - ) - if 200 <= _response.status_code < 300: - return - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) + + def list_items_live( + self, + collection_id: str, + *, + cms_locale_id: typing.Optional[str] = None, + offset: typing.Optional[float] = None, + limit: typing.Optional[float] = None, + name: typing.Optional[str] = None, + slug: typing.Optional[str] = None, + sort_by: typing.Optional[ItemsListItemsLiveRequestSortBy] = None, + sort_order: typing.Optional[ItemsListItemsLiveRequestSortOrder] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> CollectionItemList: + """ + List of all live Items within a Collection.

Required scope | `CMS:read` + + Parameters + ---------- + collection_id : str + Unique identifier for a Collection + + cms_locale_id : typing.Optional[str] + Unique identifier for a CMS Locale. This UID is different from the Site locale identifier and is listed as `cmsLocaleId` in the Sites response. To query multiple locales, input a comma separated string. + + offset : typing.Optional[float] + Offset used for pagination if the results have more than limit records + + limit : typing.Optional[float] + Maximum number of records to be returned (max limit: 100) + + name : typing.Optional[str] + The name of the item(s) + + slug : typing.Optional[str] + The slug of the item + + sort_by : typing.Optional[ItemsListItemsLiveRequestSortBy] + Sort results by the provided value + + sort_order : typing.Optional[ItemsListItemsLiveRequestSortOrder] + Sorts the results by asc or desc + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + CollectionItemList + Request was successful + + Examples + -------- + from webflow.client import Webflow + + client = Webflow( + access_token="YOUR_ACCESS_TOKEN", + ) + client.collections.items.list_items_live( + collection_id="collection_id", + ) + """ + _response = self._client_wrapper.httpx_client.request( + f"collections/{jsonable_encoder(collection_id)}/items/live", + method="GET", + params={ + "cmsLocaleId": cms_locale_id, + "offset": offset, + "limit": limit, + "name": name, + "slug": slug, + "sortBy": sort_by, + "sortOrder": sort_order, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(CollectionItemList, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) def create_item_live( - self, collection_id: str, *, request: CollectionItem, request_options: typing.Optional[RequestOptions] = None + self, + collection_id: str, + *, + id: str, + cms_locale_id: typing.Optional[str] = OMIT, + last_published: typing.Optional[str] = OMIT, + last_updated: typing.Optional[str] = OMIT, + created_on: typing.Optional[str] = OMIT, + is_archived: typing.Optional[bool] = OMIT, + is_draft: typing.Optional[bool] = OMIT, + field_data: typing.Optional[CollectionItemFieldData] = OMIT, + request_options: typing.Optional[RequestOptions] = None, ) -> None: """ Create live Item in a Collection. This Item will be published to the live site.

To create items across multiple locales, please use this endpoint.

Required scope | `CMS:write` - Parameters: - - collection_id: str. Unique identifier for a Collection + Parameters + ---------- + collection_id : str + Unique identifier for a Collection + + id : str + Unique identifier for the Item + + cms_locale_id : typing.Optional[str] + Identifier for the locale of the CMS item + + last_published : typing.Optional[str] + The date the item was last published + + last_updated : typing.Optional[str] + The date the item was last updated + + created_on : typing.Optional[str] + The date the item was created + + is_archived : typing.Optional[bool] + Boolean determining if the Item is set to archived + + is_draft : typing.Optional[bool] + Boolean determining if the Item is set to draft + + field_data : typing.Optional[CollectionItemFieldData] - - request: CollectionItem. + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- - from webflow import CollectionItem, CollectionItemFieldData + Returns + ------- + None + + Examples + -------- + from webflow import CollectionItemFieldData from webflow.client import Webflow client = Webflow( @@ -214,60 +387,48 @@ def create_item_live( ) client.collections.items.create_item_live( collection_id="collection_id", - request=CollectionItem( - id="42b720ef280c7a7a3be8cabe", - cms_locale_id="653ad57de882f528b32e810e", - last_published="2022-11-29T16:22:43.159Z", - last_updated="2022-11-17T17:19:43.282Z", - created_on="2022-11-17T17:11:57.148Z", - is_archived=False, - is_draft=False, - field_data=CollectionItemFieldData( - name="Pan Galactic Gargle Blaster Recipe", - slug="pan-galactic-gargle-blaster", - ), + id="42b720ef280c7a7a3be8cabe", + cms_locale_id="653ad57de882f528b32e810e", + last_published="2022-11-29T16:22:43.159Z", + last_updated="2022-11-17T17:19:43.282Z", + created_on="2022-11-17T17:11:57.148Z", + is_archived=False, + is_draft=False, + field_data=CollectionItemFieldData( + name="Pan Galactic Gargle Blaster Recipe", + slug="pan-galactic-gargle-blaster", ), ) """ _response = self._client_wrapper.httpx_client.request( - "POST", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"collections/{jsonable_encoder(collection_id)}/items/live" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + f"collections/{jsonable_encoder(collection_id)}/items/live", + method="POST", + json={ + "id": id, + "cmsLocaleId": cms_locale_id, + "lastPublished": last_published, + "lastUpdated": last_updated, + "createdOn": created_on, + "isArchived": is_archived, + "isDraft": is_draft, + "fieldData": field_data, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, - ) - if 200 <= _response.status_code < 300: - return - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -290,29 +451,44 @@ def create_item_for_multiple_locales( """ Create single Item in a Collection with multiple corresponding locales.

Required scope | `CMS:write` - Parameters: - - collection_id: str. Unique identifier for a Collection + Parameters + ---------- + collection_id : str + Unique identifier for a Collection + + id : str + Unique identifier for the Item - - id: str. Unique identifier for the Item + cms_locale_ids : typing.Optional[typing.Sequence[str]] + Array of identifiers for the locales where the item will be created - - cms_locale_ids: typing.Optional[typing.Sequence[str]]. Array of identifiers for the locales where the item will be created + last_published : typing.Optional[str] + The date the item was last published - - last_published: typing.Optional[str]. The date the item was last published + last_updated : typing.Optional[str] + The date the item was last updated - - last_updated: typing.Optional[str]. The date the item was last updated + created_on : typing.Optional[str] + The date the item was created - - created_on: typing.Optional[str]. The date the item was created + is_archived : typing.Optional[bool] + Boolean determining if the Item is set to archived - - is_archived: typing.Optional[bool]. Boolean determining if the Item is set to archived + is_draft : typing.Optional[bool] + Boolean determining if the Item is set to draft - - is_draft: typing.Optional[bool]. Boolean determining if the Item is set to draft + field_data : typing.Optional[BulkCollectionItemFieldData] - - field_data: typing.Optional[BulkCollectionItemFieldData]. + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Returns + ------- + None + + Examples + -------- from webflow.client import Webflow - from webflow.resources.collections import BulkCollectionItemFieldData client = Webflow( access_token="YOUR_ACCESS_TOKEN", @@ -320,69 +496,37 @@ def create_item_for_multiple_locales( client.collections.items.create_item_for_multiple_locales( collection_id="collection_id", id="580e64008c9a982ac9b8b754", - last_published="2023-03-17T18:47:35.560Z", - last_updated="2023-03-17T18:47:35.560Z", - created_on="2023-03-17T18:47:35.560Z", - field_data=BulkCollectionItemFieldData( - name="My new item", - slug="my-new-item", - ), ) """ - _request: typing.Dict[str, typing.Any] = {"id": id} - if cms_locale_ids is not OMIT: - _request["cmsLocaleIds"] = cms_locale_ids - if last_published is not OMIT: - _request["lastPublished"] = last_published - if last_updated is not OMIT: - _request["lastUpdated"] = last_updated - if created_on is not OMIT: - _request["createdOn"] = created_on - if is_archived is not OMIT: - _request["isArchived"] = is_archived - if is_draft is not OMIT: - _request["isDraft"] = is_draft - if field_data is not OMIT: - _request["fieldData"] = field_data _response = self._client_wrapper.httpx_client.request( - "POST", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"collections/{jsonable_encoder(collection_id)}/items/bulk" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + f"collections/{jsonable_encoder(collection_id)}/items/bulk", + method="POST", + json={ + "id": id, + "cmsLocaleIds": cms_locale_ids, + "lastPublished": last_published, + "lastUpdated": last_updated, + "createdOn": created_on, + "isArchived": is_archived, + "isDraft": is_draft, + "fieldData": field_data, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, - ) - if 200 <= _response.status_code < 300: - return - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -399,15 +543,27 @@ def get_item( """ Get details of a selected Collection Item.

Required scope | `CMS:read` - Parameters: - - collection_id: str. Unique identifier for a Collection + Parameters + ---------- + collection_id : str + Unique identifier for a Collection - - item_id: str. Unique identifier for an Item + item_id : str + Unique identifier for an Item - - cms_locale_id: typing.Optional[str]. Unique identifier for a CMS Locale. These UID is different from the Site locale identifier and is listed as `cmsLocaleId` in the Sites response. Applicable when using localization. + cms_locale_id : typing.Optional[str] + Unique identifier for a CMS Locale. This UID is different from the Site locale identifier and is listed as `cmsLocaleId` in the Sites response. To query multiple locales, input a comma separated string. - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + CollectionItem + Request was successful + + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -419,48 +575,24 @@ def get_item( ) """ _response = self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"collections/{jsonable_encoder(collection_id)}/items/{jsonable_encoder(item_id)}", - ), - params=jsonable_encoder( - remove_none_from_dict( - { - "cmsLocaleId": cms_locale_id, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, - ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(CollectionItem, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore + f"collections/{jsonable_encoder(collection_id)}/items/{jsonable_encoder(item_id)}", + method="GET", + params={"cmsLocaleId": cms_locale_id}, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(CollectionItem, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -471,21 +603,32 @@ def delete_item( collection_id: str, item_id: str, *, - cms_locale_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, + cms_locale_id: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None, ) -> None: """ Delete an Item from a Collection. This endpoint does not currently support bulk deletion.

Required scope | `CMS:write` - Parameters: - - collection_id: str. Unique identifier for a Collection + Parameters + ---------- + collection_id : str + Unique identifier for a Collection - - item_id: str. Unique identifier for an Item + item_id : str + Unique identifier for an Item - - cms_locale_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]]. Unique identifiers for CMS Locales. These UIDs are different from the Site locale identifier and are listed as `cmsLocaleId` in the Sites response. Applicable when using localization. + cms_locale_id : typing.Optional[str] + Unique identifier for a CMS Locale. This UID is different from the Site locale identifier and is listed as `cmsLocaleId` in the Sites response. To query multiple locales, input a comma separated string. - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + None + + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -497,48 +640,24 @@ def delete_item( ) """ _response = self._client_wrapper.httpx_client.request( - "DELETE", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"collections/{jsonable_encoder(collection_id)}/items/{jsonable_encoder(item_id)}", - ), - params=jsonable_encoder( - remove_none_from_dict( - { - "cmsLocaleIds": cms_locale_ids, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, - ) - if 200 <= _response.status_code < 300: - return - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore + f"collections/{jsonable_encoder(collection_id)}/items/{jsonable_encoder(item_id)}", + method="DELETE", + params={"cmsLocaleId": cms_locale_id}, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -549,22 +668,61 @@ def update_item( collection_id: str, item_id: str, *, - request: CollectionItem, + id: str, + cms_locale_id: typing.Optional[str] = OMIT, + last_published: typing.Optional[str] = OMIT, + last_updated: typing.Optional[str] = OMIT, + created_on: typing.Optional[str] = OMIT, + is_archived: typing.Optional[bool] = OMIT, + is_draft: typing.Optional[bool] = OMIT, + field_data: typing.Optional[CollectionItemFieldData] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> CollectionItem: """ Update a selected Item in a Collection.

Required scope | `CMS:write` - Parameters: - - collection_id: str. Unique identifier for a Collection + Parameters + ---------- + collection_id : str + Unique identifier for a Collection + + item_id : str + Unique identifier for an Item + + id : str + Unique identifier for the Item + + cms_locale_id : typing.Optional[str] + Identifier for the locale of the CMS item + + last_published : typing.Optional[str] + The date the item was last published + + last_updated : typing.Optional[str] + The date the item was last updated + + created_on : typing.Optional[str] + The date the item was created + + is_archived : typing.Optional[bool] + Boolean determining if the Item is set to archived - - item_id: str. Unique identifier for an Item + is_draft : typing.Optional[bool] + Boolean determining if the Item is set to draft - - request: CollectionItem. + field_data : typing.Optional[CollectionItemFieldData] - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- - from webflow import CollectionItem, CollectionItemFieldData + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + CollectionItem + Request was successful + + Examples + -------- + from webflow import CollectionItemFieldData from webflow.client import Webflow client = Webflow( @@ -573,79 +731,150 @@ def update_item( client.collections.items.update_item( collection_id="collection_id", item_id="item_id", - request=CollectionItem( - id="42b720ef280c7a7a3be8cabe", - cms_locale_id="653ad57de882f528b32e810e", - last_published="2022-11-29T16:22:43.159Z", - last_updated="2022-11-17T17:19:43.282Z", - created_on="2022-11-17T17:11:57.148Z", - is_archived=False, - is_draft=False, - field_data=CollectionItemFieldData( - name="Pan Galactic Gargle Blaster Recipe", - slug="pan-galactic-gargle-blaster", - ), + id="42b720ef280c7a7a3be8cabe", + cms_locale_id="653ad57de882f528b32e810e", + last_published="2022-11-29T16:22:43.159Z", + last_updated="2022-11-17T17:19:43.282Z", + created_on="2022-11-17T17:11:57.148Z", + is_archived=False, + is_draft=False, + field_data=CollectionItemFieldData( + name="Pan Galactic Gargle Blaster Recipe", + slug="pan-galactic-gargle-blaster", ), ) """ _response = self._client_wrapper.httpx_client.request( - "PATCH", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"collections/{jsonable_encoder(collection_id)}/items/{jsonable_encoder(item_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + f"collections/{jsonable_encoder(collection_id)}/items/{jsonable_encoder(item_id)}", + method="PATCH", + json={ + "id": id, + "cmsLocaleId": cms_locale_id, + "lastPublished": last_published, + "lastUpdated": last_updated, + "createdOn": created_on, + "isArchived": is_archived, + "isDraft": is_draft, + "fieldData": field_data, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, - ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(CollectionItem, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(CollectionItem, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) + + def get_item_live( + self, + collection_id: str, + item_id: str, + *, + cms_locale_id: typing.Optional[str] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> CollectionItem: + """ + Get details of a selected Collection live Item.

Required scope | `CMS:read` + + Parameters + ---------- + collection_id : str + Unique identifier for a Collection + + item_id : str + Unique identifier for an Item + + cms_locale_id : typing.Optional[str] + Unique identifier for a CMS Locale. This UID is different from the Site locale identifier and is listed as `cmsLocaleId` in the Sites response. To query multiple locales, input a comma separated string. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + CollectionItem + Request was successful + + Examples + -------- + from webflow.client import Webflow + + client = Webflow( + access_token="YOUR_ACCESS_TOKEN", + ) + client.collections.items.get_item_live( + collection_id="collection_id", + item_id="item_id", + ) + """ + _response = self._client_wrapper.httpx_client.request( + f"collections/{jsonable_encoder(collection_id)}/items/{jsonable_encoder(item_id)}/live", + method="GET", + params={"cmsLocaleId": cms_locale_id}, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(CollectionItem, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) def delete_item_live( - self, collection_id: str, item_id: str, *, request_options: typing.Optional[RequestOptions] = None + self, + collection_id: str, + item_id: str, + *, + cms_locale_id: typing.Optional[str] = None, + request_options: typing.Optional[RequestOptions] = None, ) -> None: """ - Delete a live Item from a Collection. The Item will be unpublished from the live site. This endpoint does not currently support bulk deletion.

Required scope | `CMS:write` + Remove a live item from the site. Removing a published item will unpublish the item from the live site and set it to draft. This endpoint does not currently support bulk deletion.

Required scope | `CMS:write` + + Parameters + ---------- + collection_id : str + Unique identifier for a Collection + + item_id : str + Unique identifier for an Item + + cms_locale_id : typing.Optional[str] + Unique identifier for a CMS Locale. This UID is different from the Site locale identifier and is listed as `cmsLocaleId` in the Sites response. To query multiple locales, input a comma separated string. - Parameters: - - collection_id: str. Unique identifier for a Collection + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - item_id: str. Unique identifier for an Item + Returns + ------- + None - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -657,39 +886,24 @@ def delete_item_live( ) """ _response = self._client_wrapper.httpx_client.request( - "DELETE", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"collections/{jsonable_encoder(collection_id)}/items/{jsonable_encoder(item_id)}/live", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, - ) - if 200 <= _response.status_code < 300: - return - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore + f"collections/{jsonable_encoder(collection_id)}/items/{jsonable_encoder(item_id)}/live", + method="DELETE", + params={"cmsLocaleId": cms_locale_id}, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -700,22 +914,61 @@ def update_item_live( collection_id: str, item_id: str, *, - request: CollectionItem, + id: str, + cms_locale_id: typing.Optional[str] = OMIT, + last_published: typing.Optional[str] = OMIT, + last_updated: typing.Optional[str] = OMIT, + created_on: typing.Optional[str] = OMIT, + is_archived: typing.Optional[bool] = OMIT, + is_draft: typing.Optional[bool] = OMIT, + field_data: typing.Optional[CollectionItemFieldData] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> CollectionItem: """ Update a selected live Item in a Collection. The updates for this Item will be published to the live site.

Required scope | `CMS:write` - Parameters: - - collection_id: str. Unique identifier for a Collection + Parameters + ---------- + collection_id : str + Unique identifier for a Collection + + item_id : str + Unique identifier for an Item + + id : str + Unique identifier for the Item + + cms_locale_id : typing.Optional[str] + Identifier for the locale of the CMS item + + last_published : typing.Optional[str] + The date the item was last published + + last_updated : typing.Optional[str] + The date the item was last updated + + created_on : typing.Optional[str] + The date the item was created + + is_archived : typing.Optional[bool] + Boolean determining if the Item is set to archived + + is_draft : typing.Optional[bool] + Boolean determining if the Item is set to draft + + field_data : typing.Optional[CollectionItemFieldData] - - item_id: str. Unique identifier for an Item + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - request: CollectionItem. + Returns + ------- + CollectionItem + Request was successful - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- - from webflow import CollectionItem, CollectionItemFieldData + Examples + -------- + from webflow import CollectionItemFieldData from webflow.client import Webflow client = Webflow( @@ -724,61 +977,48 @@ def update_item_live( client.collections.items.update_item_live( collection_id="collection_id", item_id="item_id", - request=CollectionItem( - id="42b720ef280c7a7a3be8cabe", - cms_locale_id="653ad57de882f528b32e810e", - last_published="2022-11-29T16:22:43.159Z", - last_updated="2022-11-17T17:19:43.282Z", - created_on="2022-11-17T17:11:57.148Z", - is_archived=False, - is_draft=False, - field_data=CollectionItemFieldData( - name="Pan Galactic Gargle Blaster Recipe", - slug="pan-galactic-gargle-blaster", - ), + id="42b720ef280c7a7a3be8cabe", + cms_locale_id="653ad57de882f528b32e810e", + last_published="2022-11-29T16:22:43.159Z", + last_updated="2022-11-17T17:19:43.282Z", + created_on="2022-11-17T17:11:57.148Z", + is_archived=False, + is_draft=False, + field_data=CollectionItemFieldData( + name="Pan Galactic Gargle Blaster Recipe", + slug="pan-galactic-gargle-blaster", ), ) """ _response = self._client_wrapper.httpx_client.request( - "PATCH", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"collections/{jsonable_encoder(collection_id)}/items/{jsonable_encoder(item_id)}/live", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + f"collections/{jsonable_encoder(collection_id)}/items/{jsonable_encoder(item_id)}/live", + method="PATCH", + json={ + "id": id, + "cmsLocaleId": cms_locale_id, + "lastPublished": last_published, + "lastUpdated": last_updated, + "createdOn": created_on, + "isArchived": is_archived, + "isDraft": is_draft, + "fieldData": field_data, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, - ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(CollectionItem, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(CollectionItem, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -790,17 +1030,26 @@ def publish_item( *, item_ids: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None, - ) -> ItemsPublishItemResponse: + ) -> None: """ Publish an item or multiple items.

Required scope | `cms:write` - Parameters: - - collection_id: str. Unique identifier for a Collection + Parameters + ---------- + collection_id : str + Unique identifier for a Collection + + item_ids : typing.Sequence[str] - - item_ids: typing.Sequence[str]. + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Returns + ------- + None + + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -812,45 +1061,25 @@ def publish_item( ) """ _response = self._client_wrapper.httpx_client.request( - "POST", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"collections/{jsonable_encoder(collection_id)}/items/publish", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder({"itemIds": item_ids}) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder({"itemIds": item_ids}), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, - ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(ItemsPublishItemResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore + f"collections/{jsonable_encoder(collection_id)}/items/publish", + method="POST", + json={"itemIds": item_ids}, + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -865,25 +1094,54 @@ async def list_items( self, collection_id: str, *, - cms_locale_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, + cms_locale_id: typing.Optional[str] = None, offset: typing.Optional[float] = None, limit: typing.Optional[float] = None, + name: typing.Optional[str] = None, + slug: typing.Optional[str] = None, + sort_by: typing.Optional[ItemsListItemsRequestSortBy] = None, + sort_order: typing.Optional[ItemsListItemsRequestSortOrder] = None, request_options: typing.Optional[RequestOptions] = None, ) -> CollectionItemList: """ List of all Items within a Collection.

Required scope | `CMS:read` - Parameters: - - collection_id: str. Unique identifier for a Collection + Parameters + ---------- + collection_id : str + Unique identifier for a Collection + + cms_locale_id : typing.Optional[str] + Unique identifier for a CMS Locale. This UID is different from the Site locale identifier and is listed as `cmsLocaleId` in the Sites response. To query multiple locales, input a comma separated string. + + offset : typing.Optional[float] + Offset used for pagination if the results have more than limit records + + limit : typing.Optional[float] + Maximum number of records to be returned (max limit: 100) + + name : typing.Optional[str] + The name of the item(s) + + slug : typing.Optional[str] + The slug of the item + + sort_by : typing.Optional[ItemsListItemsRequestSortBy] + Sort results by the provided value - - cms_locale_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]]. Unique identifiers for CMS Locales. These UIDs are different from the Site locale identifier and are listed as `cmsLocaleId` in the Sites response. Applicable when using localization. + sort_order : typing.Optional[ItemsListItemsRequestSortOrder] + Sorts the results by asc or desc - - offset: typing.Optional[float]. Offset used for pagination if the results have more than limit records + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - limit: typing.Optional[float]. Maximum number of records to be returned (max limit: 100) + Returns + ------- + CollectionItemList + Request was successful - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -894,68 +1152,92 @@ async def list_items( ) """ _response = await self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"collections/{jsonable_encoder(collection_id)}/items" - ), - params=jsonable_encoder( - remove_none_from_dict( - { - "cmsLocaleIds": cms_locale_ids, - "offset": offset, - "limit": limit, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, - ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(CollectionItemList, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore + f"collections/{jsonable_encoder(collection_id)}/items", + method="GET", + params={ + "cmsLocaleId": cms_locale_id, + "offset": offset, + "limit": limit, + "name": name, + "slug": slug, + "sortBy": sort_by, + "sortOrder": sort_order, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(CollectionItemList, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) async def create_item( - self, collection_id: str, *, request: CollectionItem, request_options: typing.Optional[RequestOptions] = None + self, + collection_id: str, + *, + id: str, + cms_locale_id: typing.Optional[str] = OMIT, + last_published: typing.Optional[str] = OMIT, + last_updated: typing.Optional[str] = OMIT, + created_on: typing.Optional[str] = OMIT, + is_archived: typing.Optional[bool] = OMIT, + is_draft: typing.Optional[bool] = OMIT, + field_data: typing.Optional[CollectionItemFieldData] = OMIT, + request_options: typing.Optional[RequestOptions] = None, ) -> None: """ Create Item in a Collection.

To create items across multiple locales, please use this endpoint.

Required scope | `CMS:write` - Parameters: - - collection_id: str. Unique identifier for a Collection + Parameters + ---------- + collection_id : str + Unique identifier for a Collection + + id : str + Unique identifier for the Item + + cms_locale_id : typing.Optional[str] + Identifier for the locale of the CMS item + + last_published : typing.Optional[str] + The date the item was last published + + last_updated : typing.Optional[str] + The date the item was last updated - - request: CollectionItem. + created_on : typing.Optional[str] + The date the item was created - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- - from webflow import CollectionItem, CollectionItemFieldData + is_archived : typing.Optional[bool] + Boolean determining if the Item is set to archived + + is_draft : typing.Optional[bool] + Boolean determining if the Item is set to draft + + field_data : typing.Optional[CollectionItemFieldData] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + None + + Examples + -------- + from webflow import CollectionItemFieldData from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -963,79 +1245,201 @@ async def create_item( ) await client.collections.items.create_item( collection_id="collection_id", - request=CollectionItem( - id="42b720ef280c7a7a3be8cabe", - cms_locale_id="653ad57de882f528b32e810e", - last_published="2022-11-29T16:22:43.159Z", - last_updated="2022-11-17T17:19:43.282Z", - created_on="2022-11-17T17:11:57.148Z", - is_archived=False, - is_draft=False, - field_data=CollectionItemFieldData( - name="Pan Galactic Gargle Blaster Recipe", - slug="pan-galactic-gargle-blaster", - ), + id="42b720ef280c7a7a3be8cabe", + cms_locale_id="653ad57de882f528b32e810e", + last_published="2022-11-29T16:22:43.159Z", + last_updated="2022-11-17T17:19:43.282Z", + created_on="2022-11-17T17:11:57.148Z", + is_archived=False, + is_draft=False, + field_data=CollectionItemFieldData( + name="Pan Galactic Gargle Blaster Recipe", + slug="pan-galactic-gargle-blaster", ), ) """ _response = await self._client_wrapper.httpx_client.request( - "POST", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"collections/{jsonable_encoder(collection_id)}/items" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + f"collections/{jsonable_encoder(collection_id)}/items", + method="POST", + json={ + "id": id, + "cmsLocaleId": cms_locale_id, + "lastPublished": last_published, + "lastUpdated": last_updated, + "createdOn": created_on, + "isArchived": is_archived, + "isDraft": is_draft, + "fieldData": field_data, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, - ) - if 200 <= _response.status_code < 300: - return - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) + + async def list_items_live( + self, + collection_id: str, + *, + cms_locale_id: typing.Optional[str] = None, + offset: typing.Optional[float] = None, + limit: typing.Optional[float] = None, + name: typing.Optional[str] = None, + slug: typing.Optional[str] = None, + sort_by: typing.Optional[ItemsListItemsLiveRequestSortBy] = None, + sort_order: typing.Optional[ItemsListItemsLiveRequestSortOrder] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> CollectionItemList: + """ + List of all live Items within a Collection.

Required scope | `CMS:read` + + Parameters + ---------- + collection_id : str + Unique identifier for a Collection + + cms_locale_id : typing.Optional[str] + Unique identifier for a CMS Locale. This UID is different from the Site locale identifier and is listed as `cmsLocaleId` in the Sites response. To query multiple locales, input a comma separated string. + + offset : typing.Optional[float] + Offset used for pagination if the results have more than limit records + + limit : typing.Optional[float] + Maximum number of records to be returned (max limit: 100) + + name : typing.Optional[str] + The name of the item(s) + + slug : typing.Optional[str] + The slug of the item + + sort_by : typing.Optional[ItemsListItemsLiveRequestSortBy] + Sort results by the provided value + + sort_order : typing.Optional[ItemsListItemsLiveRequestSortOrder] + Sorts the results by asc or desc + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + CollectionItemList + Request was successful + + Examples + -------- + from webflow.client import AsyncWebflow + + client = AsyncWebflow( + access_token="YOUR_ACCESS_TOKEN", + ) + await client.collections.items.list_items_live( + collection_id="collection_id", + ) + """ + _response = await self._client_wrapper.httpx_client.request( + f"collections/{jsonable_encoder(collection_id)}/items/live", + method="GET", + params={ + "cmsLocaleId": cms_locale_id, + "offset": offset, + "limit": limit, + "name": name, + "slug": slug, + "sortBy": sort_by, + "sortOrder": sort_order, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(CollectionItemList, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) async def create_item_live( - self, collection_id: str, *, request: CollectionItem, request_options: typing.Optional[RequestOptions] = None + self, + collection_id: str, + *, + id: str, + cms_locale_id: typing.Optional[str] = OMIT, + last_published: typing.Optional[str] = OMIT, + last_updated: typing.Optional[str] = OMIT, + created_on: typing.Optional[str] = OMIT, + is_archived: typing.Optional[bool] = OMIT, + is_draft: typing.Optional[bool] = OMIT, + field_data: typing.Optional[CollectionItemFieldData] = OMIT, + request_options: typing.Optional[RequestOptions] = None, ) -> None: """ Create live Item in a Collection. This Item will be published to the live site.

To create items across multiple locales, please use this endpoint.

Required scope | `CMS:write` - Parameters: - - collection_id: str. Unique identifier for a Collection + Parameters + ---------- + collection_id : str + Unique identifier for a Collection + + id : str + Unique identifier for the Item + + cms_locale_id : typing.Optional[str] + Identifier for the locale of the CMS item + + last_published : typing.Optional[str] + The date the item was last published + + last_updated : typing.Optional[str] + The date the item was last updated + + created_on : typing.Optional[str] + The date the item was created + + is_archived : typing.Optional[bool] + Boolean determining if the Item is set to archived + + is_draft : typing.Optional[bool] + Boolean determining if the Item is set to draft + + field_data : typing.Optional[CollectionItemFieldData] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - request: CollectionItem. + Returns + ------- + None - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- - from webflow import CollectionItem, CollectionItemFieldData + Examples + -------- + from webflow import CollectionItemFieldData from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -1043,60 +1447,48 @@ async def create_item_live( ) await client.collections.items.create_item_live( collection_id="collection_id", - request=CollectionItem( - id="42b720ef280c7a7a3be8cabe", - cms_locale_id="653ad57de882f528b32e810e", - last_published="2022-11-29T16:22:43.159Z", - last_updated="2022-11-17T17:19:43.282Z", - created_on="2022-11-17T17:11:57.148Z", - is_archived=False, - is_draft=False, - field_data=CollectionItemFieldData( - name="Pan Galactic Gargle Blaster Recipe", - slug="pan-galactic-gargle-blaster", - ), + id="42b720ef280c7a7a3be8cabe", + cms_locale_id="653ad57de882f528b32e810e", + last_published="2022-11-29T16:22:43.159Z", + last_updated="2022-11-17T17:19:43.282Z", + created_on="2022-11-17T17:11:57.148Z", + is_archived=False, + is_draft=False, + field_data=CollectionItemFieldData( + name="Pan Galactic Gargle Blaster Recipe", + slug="pan-galactic-gargle-blaster", ), ) """ _response = await self._client_wrapper.httpx_client.request( - "POST", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"collections/{jsonable_encoder(collection_id)}/items/live" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + f"collections/{jsonable_encoder(collection_id)}/items/live", + method="POST", + json={ + "id": id, + "cmsLocaleId": cms_locale_id, + "lastPublished": last_published, + "lastUpdated": last_updated, + "createdOn": created_on, + "isArchived": is_archived, + "isDraft": is_draft, + "fieldData": field_data, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, - ) - if 200 <= _response.status_code < 300: - return - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -1119,29 +1511,44 @@ async def create_item_for_multiple_locales( """ Create single Item in a Collection with multiple corresponding locales.

Required scope | `CMS:write` - Parameters: - - collection_id: str. Unique identifier for a Collection + Parameters + ---------- + collection_id : str + Unique identifier for a Collection + + id : str + Unique identifier for the Item + + cms_locale_ids : typing.Optional[typing.Sequence[str]] + Array of identifiers for the locales where the item will be created - - id: str. Unique identifier for the Item + last_published : typing.Optional[str] + The date the item was last published - - cms_locale_ids: typing.Optional[typing.Sequence[str]]. Array of identifiers for the locales where the item will be created + last_updated : typing.Optional[str] + The date the item was last updated - - last_published: typing.Optional[str]. The date the item was last published + created_on : typing.Optional[str] + The date the item was created - - last_updated: typing.Optional[str]. The date the item was last updated + is_archived : typing.Optional[bool] + Boolean determining if the Item is set to archived - - created_on: typing.Optional[str]. The date the item was created + is_draft : typing.Optional[bool] + Boolean determining if the Item is set to draft - - is_archived: typing.Optional[bool]. Boolean determining if the Item is set to archived + field_data : typing.Optional[BulkCollectionItemFieldData] - - is_draft: typing.Optional[bool]. Boolean determining if the Item is set to draft + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - field_data: typing.Optional[BulkCollectionItemFieldData]. + Returns + ------- + None - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import AsyncWebflow - from webflow.resources.collections import BulkCollectionItemFieldData client = AsyncWebflow( access_token="YOUR_ACCESS_TOKEN", @@ -1149,69 +1556,37 @@ async def create_item_for_multiple_locales( await client.collections.items.create_item_for_multiple_locales( collection_id="collection_id", id="580e64008c9a982ac9b8b754", - last_published="2023-03-17T18:47:35.560Z", - last_updated="2023-03-17T18:47:35.560Z", - created_on="2023-03-17T18:47:35.560Z", - field_data=BulkCollectionItemFieldData( - name="My new item", - slug="my-new-item", - ), ) """ - _request: typing.Dict[str, typing.Any] = {"id": id} - if cms_locale_ids is not OMIT: - _request["cmsLocaleIds"] = cms_locale_ids - if last_published is not OMIT: - _request["lastPublished"] = last_published - if last_updated is not OMIT: - _request["lastUpdated"] = last_updated - if created_on is not OMIT: - _request["createdOn"] = created_on - if is_archived is not OMIT: - _request["isArchived"] = is_archived - if is_draft is not OMIT: - _request["isDraft"] = is_draft - if field_data is not OMIT: - _request["fieldData"] = field_data _response = await self._client_wrapper.httpx_client.request( - "POST", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"collections/{jsonable_encoder(collection_id)}/items/bulk" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + f"collections/{jsonable_encoder(collection_id)}/items/bulk", + method="POST", + json={ + "id": id, + "cmsLocaleIds": cms_locale_ids, + "lastPublished": last_published, + "lastUpdated": last_updated, + "createdOn": created_on, + "isArchived": is_archived, + "isDraft": is_draft, + "fieldData": field_data, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, - ) - if 200 <= _response.status_code < 300: - return - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -1228,15 +1603,27 @@ async def get_item( """ Get details of a selected Collection Item.

Required scope | `CMS:read` - Parameters: - - collection_id: str. Unique identifier for a Collection + Parameters + ---------- + collection_id : str + Unique identifier for a Collection + + item_id : str + Unique identifier for an Item - - item_id: str. Unique identifier for an Item + cms_locale_id : typing.Optional[str] + Unique identifier for a CMS Locale. This UID is different from the Site locale identifier and is listed as `cmsLocaleId` in the Sites response. To query multiple locales, input a comma separated string. - - cms_locale_id: typing.Optional[str]. Unique identifier for a CMS Locale. These UID is different from the Site locale identifier and is listed as `cmsLocaleId` in the Sites response. Applicable when using localization. + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Returns + ------- + CollectionItem + Request was successful + + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -1248,48 +1635,24 @@ async def get_item( ) """ _response = await self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"collections/{jsonable_encoder(collection_id)}/items/{jsonable_encoder(item_id)}", - ), - params=jsonable_encoder( - remove_none_from_dict( - { - "cmsLocaleId": cms_locale_id, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, - ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(CollectionItem, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore + f"collections/{jsonable_encoder(collection_id)}/items/{jsonable_encoder(item_id)}", + method="GET", + params={"cmsLocaleId": cms_locale_id}, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(CollectionItem, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -1300,21 +1663,32 @@ async def delete_item( collection_id: str, item_id: str, *, - cms_locale_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, + cms_locale_id: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None, ) -> None: """ Delete an Item from a Collection. This endpoint does not currently support bulk deletion.

Required scope | `CMS:write` - Parameters: - - collection_id: str. Unique identifier for a Collection + Parameters + ---------- + collection_id : str + Unique identifier for a Collection + + item_id : str + Unique identifier for an Item - - item_id: str. Unique identifier for an Item + cms_locale_id : typing.Optional[str] + Unique identifier for a CMS Locale. This UID is different from the Site locale identifier and is listed as `cmsLocaleId` in the Sites response. To query multiple locales, input a comma separated string. - - cms_locale_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]]. Unique identifiers for CMS Locales. These UIDs are different from the Site locale identifier and are listed as `cmsLocaleId` in the Sites response. Applicable when using localization. + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Returns + ------- + None + + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -1326,48 +1700,24 @@ async def delete_item( ) """ _response = await self._client_wrapper.httpx_client.request( - "DELETE", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"collections/{jsonable_encoder(collection_id)}/items/{jsonable_encoder(item_id)}", - ), - params=jsonable_encoder( - remove_none_from_dict( - { - "cmsLocaleIds": cms_locale_ids, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, - ) - if 200 <= _response.status_code < 300: - return - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore + f"collections/{jsonable_encoder(collection_id)}/items/{jsonable_encoder(item_id)}", + method="DELETE", + params={"cmsLocaleId": cms_locale_id}, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -1378,22 +1728,61 @@ async def update_item( collection_id: str, item_id: str, *, - request: CollectionItem, + id: str, + cms_locale_id: typing.Optional[str] = OMIT, + last_published: typing.Optional[str] = OMIT, + last_updated: typing.Optional[str] = OMIT, + created_on: typing.Optional[str] = OMIT, + is_archived: typing.Optional[bool] = OMIT, + is_draft: typing.Optional[bool] = OMIT, + field_data: typing.Optional[CollectionItemFieldData] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> CollectionItem: """ Update a selected Item in a Collection.

Required scope | `CMS:write` - Parameters: - - collection_id: str. Unique identifier for a Collection + Parameters + ---------- + collection_id : str + Unique identifier for a Collection + + item_id : str + Unique identifier for an Item + + id : str + Unique identifier for the Item + + cms_locale_id : typing.Optional[str] + Identifier for the locale of the CMS item + + last_published : typing.Optional[str] + The date the item was last published + + last_updated : typing.Optional[str] + The date the item was last updated + + created_on : typing.Optional[str] + The date the item was created + + is_archived : typing.Optional[bool] + Boolean determining if the Item is set to archived + + is_draft : typing.Optional[bool] + Boolean determining if the Item is set to draft - - item_id: str. Unique identifier for an Item + field_data : typing.Optional[CollectionItemFieldData] - - request: CollectionItem. + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- - from webflow import CollectionItem, CollectionItemFieldData + Returns + ------- + CollectionItem + Request was successful + + Examples + -------- + from webflow import CollectionItemFieldData from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -1402,79 +1791,150 @@ async def update_item( await client.collections.items.update_item( collection_id="collection_id", item_id="item_id", - request=CollectionItem( - id="42b720ef280c7a7a3be8cabe", - cms_locale_id="653ad57de882f528b32e810e", - last_published="2022-11-29T16:22:43.159Z", - last_updated="2022-11-17T17:19:43.282Z", - created_on="2022-11-17T17:11:57.148Z", - is_archived=False, - is_draft=False, - field_data=CollectionItemFieldData( - name="Pan Galactic Gargle Blaster Recipe", - slug="pan-galactic-gargle-blaster", - ), + id="42b720ef280c7a7a3be8cabe", + cms_locale_id="653ad57de882f528b32e810e", + last_published="2022-11-29T16:22:43.159Z", + last_updated="2022-11-17T17:19:43.282Z", + created_on="2022-11-17T17:11:57.148Z", + is_archived=False, + is_draft=False, + field_data=CollectionItemFieldData( + name="Pan Galactic Gargle Blaster Recipe", + slug="pan-galactic-gargle-blaster", ), ) """ _response = await self._client_wrapper.httpx_client.request( - "PATCH", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"collections/{jsonable_encoder(collection_id)}/items/{jsonable_encoder(item_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + f"collections/{jsonable_encoder(collection_id)}/items/{jsonable_encoder(item_id)}", + method="PATCH", + json={ + "id": id, + "cmsLocaleId": cms_locale_id, + "lastPublished": last_published, + "lastUpdated": last_updated, + "createdOn": created_on, + "isArchived": is_archived, + "isDraft": is_draft, + "fieldData": field_data, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, - ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(CollectionItem, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(CollectionItem, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) + + async def get_item_live( + self, + collection_id: str, + item_id: str, + *, + cms_locale_id: typing.Optional[str] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> CollectionItem: + """ + Get details of a selected Collection live Item.

Required scope | `CMS:read` + + Parameters + ---------- + collection_id : str + Unique identifier for a Collection + + item_id : str + Unique identifier for an Item + + cms_locale_id : typing.Optional[str] + Unique identifier for a CMS Locale. This UID is different from the Site locale identifier and is listed as `cmsLocaleId` in the Sites response. To query multiple locales, input a comma separated string. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + CollectionItem + Request was successful + + Examples + -------- + from webflow.client import AsyncWebflow + + client = AsyncWebflow( + access_token="YOUR_ACCESS_TOKEN", + ) + await client.collections.items.get_item_live( + collection_id="collection_id", + item_id="item_id", + ) + """ + _response = await self._client_wrapper.httpx_client.request( + f"collections/{jsonable_encoder(collection_id)}/items/{jsonable_encoder(item_id)}/live", + method="GET", + params={"cmsLocaleId": cms_locale_id}, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(CollectionItem, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) async def delete_item_live( - self, collection_id: str, item_id: str, *, request_options: typing.Optional[RequestOptions] = None + self, + collection_id: str, + item_id: str, + *, + cms_locale_id: typing.Optional[str] = None, + request_options: typing.Optional[RequestOptions] = None, ) -> None: """ - Delete a live Item from a Collection. The Item will be unpublished from the live site. This endpoint does not currently support bulk deletion.

Required scope | `CMS:write` + Remove a live item from the site. Removing a published item will unpublish the item from the live site and set it to draft. This endpoint does not currently support bulk deletion.

Required scope | `CMS:write` + + Parameters + ---------- + collection_id : str + Unique identifier for a Collection + + item_id : str + Unique identifier for an Item + + cms_locale_id : typing.Optional[str] + Unique identifier for a CMS Locale. This UID is different from the Site locale identifier and is listed as `cmsLocaleId` in the Sites response. To query multiple locales, input a comma separated string. - Parameters: - - collection_id: str. Unique identifier for a Collection + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - item_id: str. Unique identifier for an Item + Returns + ------- + None - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -1486,39 +1946,24 @@ async def delete_item_live( ) """ _response = await self._client_wrapper.httpx_client.request( - "DELETE", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"collections/{jsonable_encoder(collection_id)}/items/{jsonable_encoder(item_id)}/live", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, - ) - if 200 <= _response.status_code < 300: - return - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore + f"collections/{jsonable_encoder(collection_id)}/items/{jsonable_encoder(item_id)}/live", + method="DELETE", + params={"cmsLocaleId": cms_locale_id}, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -1529,22 +1974,61 @@ async def update_item_live( collection_id: str, item_id: str, *, - request: CollectionItem, + id: str, + cms_locale_id: typing.Optional[str] = OMIT, + last_published: typing.Optional[str] = OMIT, + last_updated: typing.Optional[str] = OMIT, + created_on: typing.Optional[str] = OMIT, + is_archived: typing.Optional[bool] = OMIT, + is_draft: typing.Optional[bool] = OMIT, + field_data: typing.Optional[CollectionItemFieldData] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> CollectionItem: """ Update a selected live Item in a Collection. The updates for this Item will be published to the live site.

Required scope | `CMS:write` - Parameters: - - collection_id: str. Unique identifier for a Collection + Parameters + ---------- + collection_id : str + Unique identifier for a Collection + + item_id : str + Unique identifier for an Item + + id : str + Unique identifier for the Item + + cms_locale_id : typing.Optional[str] + Identifier for the locale of the CMS item + + last_published : typing.Optional[str] + The date the item was last published + + last_updated : typing.Optional[str] + The date the item was last updated + + created_on : typing.Optional[str] + The date the item was created + + is_archived : typing.Optional[bool] + Boolean determining if the Item is set to archived + + is_draft : typing.Optional[bool] + Boolean determining if the Item is set to draft + + field_data : typing.Optional[CollectionItemFieldData] - - item_id: str. Unique identifier for an Item + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - request: CollectionItem. + Returns + ------- + CollectionItem + Request was successful - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- - from webflow import CollectionItem, CollectionItemFieldData + Examples + -------- + from webflow import CollectionItemFieldData from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -1553,61 +2037,48 @@ async def update_item_live( await client.collections.items.update_item_live( collection_id="collection_id", item_id="item_id", - request=CollectionItem( - id="42b720ef280c7a7a3be8cabe", - cms_locale_id="653ad57de882f528b32e810e", - last_published="2022-11-29T16:22:43.159Z", - last_updated="2022-11-17T17:19:43.282Z", - created_on="2022-11-17T17:11:57.148Z", - is_archived=False, - is_draft=False, - field_data=CollectionItemFieldData( - name="Pan Galactic Gargle Blaster Recipe", - slug="pan-galactic-gargle-blaster", - ), + id="42b720ef280c7a7a3be8cabe", + cms_locale_id="653ad57de882f528b32e810e", + last_published="2022-11-29T16:22:43.159Z", + last_updated="2022-11-17T17:19:43.282Z", + created_on="2022-11-17T17:11:57.148Z", + is_archived=False, + is_draft=False, + field_data=CollectionItemFieldData( + name="Pan Galactic Gargle Blaster Recipe", + slug="pan-galactic-gargle-blaster", ), ) """ _response = await self._client_wrapper.httpx_client.request( - "PATCH", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"collections/{jsonable_encoder(collection_id)}/items/{jsonable_encoder(item_id)}/live", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + f"collections/{jsonable_encoder(collection_id)}/items/{jsonable_encoder(item_id)}/live", + method="PATCH", + json={ + "id": id, + "cmsLocaleId": cms_locale_id, + "lastPublished": last_published, + "lastUpdated": last_updated, + "createdOn": created_on, + "isArchived": is_archived, + "isDraft": is_draft, + "fieldData": field_data, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, - ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(CollectionItem, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(CollectionItem, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -1619,17 +2090,26 @@ async def publish_item( *, item_ids: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None, - ) -> ItemsPublishItemResponse: + ) -> None: """ Publish an item or multiple items.

Required scope | `cms:write` - Parameters: - - collection_id: str. Unique identifier for a Collection + Parameters + ---------- + collection_id : str + Unique identifier for a Collection + + item_ids : typing.Sequence[str] - - item_ids: typing.Sequence[str]. + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Returns + ------- + None + + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -1641,45 +2121,25 @@ async def publish_item( ) """ _response = await self._client_wrapper.httpx_client.request( - "POST", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"collections/{jsonable_encoder(collection_id)}/items/publish", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder({"itemIds": item_ids}) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder({"itemIds": item_ids}), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, - ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(ItemsPublishItemResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore + f"collections/{jsonable_encoder(collection_id)}/items/publish", + method="POST", + json={"itemIds": item_ids}, + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/src/webflow/resources/collections/resources/items/types/__init__.py b/src/webflow/resources/collections/resources/items/types/__init__.py index b313482..fc48f35 100644 --- a/src/webflow/resources/collections/resources/items/types/__init__.py +++ b/src/webflow/resources/collections/resources/items/types/__init__.py @@ -1,6 +1,15 @@ # This file was auto-generated by Fern from our API Definition. from .bulk_collection_item_field_data import BulkCollectionItemFieldData -from .items_publish_item_response import ItemsPublishItemResponse +from .items_list_items_live_request_sort_by import ItemsListItemsLiveRequestSortBy +from .items_list_items_live_request_sort_order import ItemsListItemsLiveRequestSortOrder +from .items_list_items_request_sort_by import ItemsListItemsRequestSortBy +from .items_list_items_request_sort_order import ItemsListItemsRequestSortOrder -__all__ = ["BulkCollectionItemFieldData", "ItemsPublishItemResponse"] +__all__ = [ + "BulkCollectionItemFieldData", + "ItemsListItemsLiveRequestSortBy", + "ItemsListItemsLiveRequestSortOrder", + "ItemsListItemsRequestSortBy", + "ItemsListItemsRequestSortOrder", +] diff --git a/src/webflow/resources/collections/resources/items/types/bulk_collection_item_field_data.py b/src/webflow/resources/collections/resources/items/types/bulk_collection_item_field_data.py index 18cb175..dadc943 100644 --- a/src/webflow/resources/collections/resources/items/types/bulk_collection_item_field_data.py +++ b/src/webflow/resources/collections/resources/items/types/bulk_collection_item_field_data.py @@ -4,29 +4,34 @@ import typing from ......core.datetime_utils import serialize_datetime +from ......core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore +class BulkCollectionItemFieldData(pydantic_v1.BaseModel): + name: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + Name of the Item + """ -class BulkCollectionItemFieldData(pydantic.BaseModel): - name: typing.Optional[str] = pydantic.Field(default=None, description="Name of the Item") - slug: typing.Optional[str] = pydantic.Field( - default=None, - description="URL structure of the Item in your site. Note: Updates to an item slug will break all links referencing the old slug.", - ) + slug: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + URL structure of the Item in your site. Note: Updates to an item slug will break all links referencing the old slug. + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/resources/collections/resources/items/types/items_list_items_live_request_sort_by.py b/src/webflow/resources/collections/resources/items/types/items_list_items_live_request_sort_by.py new file mode 100644 index 0000000..f9f5583 --- /dev/null +++ b/src/webflow/resources/collections/resources/items/types/items_list_items_live_request_sort_by.py @@ -0,0 +1,25 @@ +# This file was auto-generated by Fern from our API Definition. + +import enum +import typing + +T_Result = typing.TypeVar("T_Result") + + +class ItemsListItemsLiveRequestSortBy(str, enum.Enum): + LAST_PUBLISHED = "lastPublished" + NAME = "name" + SLUG = "slug" + + def visit( + self, + last_published: typing.Callable[[], T_Result], + name: typing.Callable[[], T_Result], + slug: typing.Callable[[], T_Result], + ) -> T_Result: + if self is ItemsListItemsLiveRequestSortBy.LAST_PUBLISHED: + return last_published() + if self is ItemsListItemsLiveRequestSortBy.NAME: + return name() + if self is ItemsListItemsLiveRequestSortBy.SLUG: + return slug() diff --git a/src/webflow/resources/collections/resources/items/types/items_list_items_live_request_sort_order.py b/src/webflow/resources/collections/resources/items/types/items_list_items_live_request_sort_order.py new file mode 100644 index 0000000..6ce16f4 --- /dev/null +++ b/src/webflow/resources/collections/resources/items/types/items_list_items_live_request_sort_order.py @@ -0,0 +1,17 @@ +# This file was auto-generated by Fern from our API Definition. + +import enum +import typing + +T_Result = typing.TypeVar("T_Result") + + +class ItemsListItemsLiveRequestSortOrder(str, enum.Enum): + ASC = "asc" + DESC = "desc" + + def visit(self, asc: typing.Callable[[], T_Result], desc: typing.Callable[[], T_Result]) -> T_Result: + if self is ItemsListItemsLiveRequestSortOrder.ASC: + return asc() + if self is ItemsListItemsLiveRequestSortOrder.DESC: + return desc() diff --git a/src/webflow/resources/collections/resources/items/types/items_list_items_request_sort_by.py b/src/webflow/resources/collections/resources/items/types/items_list_items_request_sort_by.py new file mode 100644 index 0000000..459f68f --- /dev/null +++ b/src/webflow/resources/collections/resources/items/types/items_list_items_request_sort_by.py @@ -0,0 +1,25 @@ +# This file was auto-generated by Fern from our API Definition. + +import enum +import typing + +T_Result = typing.TypeVar("T_Result") + + +class ItemsListItemsRequestSortBy(str, enum.Enum): + LAST_PUBLISHED = "lastPublished" + NAME = "name" + SLUG = "slug" + + def visit( + self, + last_published: typing.Callable[[], T_Result], + name: typing.Callable[[], T_Result], + slug: typing.Callable[[], T_Result], + ) -> T_Result: + if self is ItemsListItemsRequestSortBy.LAST_PUBLISHED: + return last_published() + if self is ItemsListItemsRequestSortBy.NAME: + return name() + if self is ItemsListItemsRequestSortBy.SLUG: + return slug() diff --git a/src/webflow/resources/collections/resources/items/types/items_list_items_request_sort_order.py b/src/webflow/resources/collections/resources/items/types/items_list_items_request_sort_order.py new file mode 100644 index 0000000..a27080d --- /dev/null +++ b/src/webflow/resources/collections/resources/items/types/items_list_items_request_sort_order.py @@ -0,0 +1,17 @@ +# This file was auto-generated by Fern from our API Definition. + +import enum +import typing + +T_Result = typing.TypeVar("T_Result") + + +class ItemsListItemsRequestSortOrder(str, enum.Enum): + ASC = "asc" + DESC = "desc" + + def visit(self, asc: typing.Callable[[], T_Result], desc: typing.Callable[[], T_Result]) -> T_Result: + if self is ItemsListItemsRequestSortOrder.ASC: + return asc() + if self is ItemsListItemsRequestSortOrder.DESC: + return desc() diff --git a/src/webflow/resources/collections/resources/items/types/items_publish_item_response.py b/src/webflow/resources/collections/resources/items/types/items_publish_item_response.py deleted file mode 100644 index 0ecc85f..0000000 --- a/src/webflow/resources/collections/resources/items/types/items_publish_item_response.py +++ /dev/null @@ -1,30 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import datetime as dt -import typing - -from ......core.datetime_utils import serialize_datetime - -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - - -class ItemsPublishItemResponse(pydantic.BaseModel): - published_item_ids: typing.Optional[typing.List[str]] = pydantic.Field(alias="publishedItemIds", default=None) - errors: typing.Optional[typing.List[str]] = None - - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) - - class Config: - frozen = True - smart_union = True - allow_population_by_field_name = True - json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/resources/ecommerce/client.py b/src/webflow/resources/ecommerce/client.py index d1d7129..3baa775 100644 --- a/src/webflow/resources/ecommerce/client.py +++ b/src/webflow/resources/ecommerce/client.py @@ -1,13 +1,12 @@ # This file was auto-generated by Fern from our API Definition. import typing -import urllib.parse from json.decoder import JSONDecodeError from ...core.api_error import ApiError from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ...core.jsonable_encoder import jsonable_encoder -from ...core.remove_none_from_dict import remove_none_from_dict +from ...core.pydantic_utilities import pydantic_v1 from ...core.request_options import RequestOptions from ...errors.bad_request_error import BadRequestError from ...errors.conflict_error import ConflictError @@ -18,11 +17,6 @@ from ...errors.unauthorized_error import UnauthorizedError from ...types.ecommerce_settings import EcommerceSettings -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - class EcommerceClient: def __init__(self, *, client_wrapper: SyncClientWrapper): @@ -36,11 +30,21 @@ def get_settings( Required scope | `ecommerce:read` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + EcommerceSettings + Request was successful - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -51,42 +55,25 @@ def get_settings( ) """ _response = self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/ecommerce/settings" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/ecommerce/settings", method="GET", request_options=request_options ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(EcommerceSettings, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 409: - raise ConflictError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(EcommerceSettings, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 409: + raise ConflictError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -105,11 +92,21 @@ async def get_settings( Required scope | `ecommerce:read` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + EcommerceSettings + Request was successful - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -120,42 +117,25 @@ async def get_settings( ) """ _response = await self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/ecommerce/settings" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/ecommerce/settings", method="GET", request_options=request_options ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(EcommerceSettings, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 409: - raise ConflictError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(EcommerceSettings, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 409: + raise ConflictError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/src/webflow/resources/forms/client.py b/src/webflow/resources/forms/client.py index e186f96..d5a86a0 100644 --- a/src/webflow/resources/forms/client.py +++ b/src/webflow/resources/forms/client.py @@ -1,13 +1,12 @@ # This file was auto-generated by Fern from our API Definition. import typing -import urllib.parse from json.decoder import JSONDecodeError from ...core.api_error import ApiError from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ...core.jsonable_encoder import jsonable_encoder -from ...core.remove_none_from_dict import remove_none_from_dict +from ...core.pydantic_utilities import pydantic_v1 from ...core.request_options import RequestOptions from ...errors.bad_request_error import BadRequestError from ...errors.conflict_error import ConflictError @@ -21,11 +20,6 @@ from ...types.form_submission import FormSubmission from ...types.form_submission_list import FormSubmissionList -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -45,15 +39,27 @@ def list( """ List forms for a given site

Required scope | `forms:read` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site + + limit : typing.Optional[float] + Maximum number of records to be returned (max limit: 100) + + offset : typing.Optional[float] + Offset used for pagination if the results have more than limit records - - limit: typing.Optional[float]. Maximum number of records to be returned (max limit: 100) + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - offset: typing.Optional[float]. Offset used for pagination if the results have more than limit records + Returns + ------- + FormList + Request was successful - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -64,50 +70,28 @@ def list( ) """ _response = self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/forms"), - params=jsonable_encoder( - remove_none_from_dict( - { - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/forms", + method="GET", + params={"limit": limit, "offset": offset}, + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(FormList, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 409: - raise ConflictError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(FormList, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 409: + raise ConflictError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -117,11 +101,21 @@ def get(self, form_id: str, *, request_options: typing.Optional[RequestOptions] """ Get information about a given form

Required scope | `forms:read` - Parameters: - - form_id: str. Unique identifier for a Form + Parameters + ---------- + form_id : str + Unique identifier for a Form - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + Form + Request was successful + + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -132,38 +126,23 @@ def get(self, form_id: str, *, request_options: typing.Optional[RequestOptions] ) """ _response = self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"forms/{jsonable_encoder(form_id)}"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"forms/{jsonable_encoder(form_id)}", method="GET", request_options=request_options ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Form, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(Form, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -175,11 +154,21 @@ def list_submissions( """ List form submissions for a given form

Required scope | `forms:read` - Parameters: - - form_id: str. Unique identifier for a Form + Parameters + ---------- + form_id : str + Unique identifier for a Form + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Returns + ------- + FormSubmissionList + Request was successful + + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -190,40 +179,23 @@ def list_submissions( ) """ _response = self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"forms/{jsonable_encoder(form_id)}/submissions" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"forms/{jsonable_encoder(form_id)}/submissions", method="GET", request_options=request_options ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(FormSubmissionList, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(FormSubmissionList, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -235,11 +207,21 @@ def get_submission( """ Get information about a given form submission

Required scope | `forms:read` - Parameters: - - form_submission_id: str. Unique identifier for a Form Submission + Parameters + ---------- + form_submission_id : str + Unique identifier for a Form Submission + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + FormSubmission + Request was successful - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -250,40 +232,23 @@ def get_submission( ) """ _response = self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"form_submissions/{jsonable_encoder(form_submission_id)}" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"form_submissions/{jsonable_encoder(form_submission_id)}", method="GET", request_options=request_options ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(FormSubmission, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(FormSubmission, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -299,13 +264,24 @@ def update_submission( """ Update hidden fields on a form submission

Required scope | `forms:write` - Parameters: - - form_submission_id: str. Unique identifier for a Form Submission + Parameters + ---------- + form_submission_id : str + Unique identifier for a Form Submission + + form_submission_data : typing.Optional[typing.Dict[str, typing.Any]] + An existing **hidden field** defined on the form schema, and the corresponding value to set + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - form_submission_data: typing.Optional[typing.Dict[str, typing.Any]]. An existing **hidden field** defined on the form schema, and the corresponding value to set + Returns + ------- + FormSubmission + Request was successful - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -315,52 +291,30 @@ def update_submission( form_submission_id="form_submission_id", ) """ - _request: typing.Dict[str, typing.Any] = {} - if form_submission_data is not OMIT: - _request["formSubmissionData"] = form_submission_data _response = self._client_wrapper.httpx_client.request( - "PATCH", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"form_submissions/{jsonable_encoder(form_submission_id)}" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"form_submissions/{jsonable_encoder(form_submission_id)}", + method="PATCH", + json={"formSubmissionData": form_submission_data}, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(FormSubmission, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 409: - raise ConflictError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(FormSubmission, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 409: + raise ConflictError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -382,15 +336,27 @@ async def list( """ List forms for a given site

Required scope | `forms:read` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site - - limit: typing.Optional[float]. Maximum number of records to be returned (max limit: 100) + limit : typing.Optional[float] + Maximum number of records to be returned (max limit: 100) - - offset: typing.Optional[float]. Offset used for pagination if the results have more than limit records + offset : typing.Optional[float] + Offset used for pagination if the results have more than limit records - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + FormList + Request was successful + + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -401,50 +367,28 @@ async def list( ) """ _response = await self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/forms"), - params=jsonable_encoder( - remove_none_from_dict( - { - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/forms", + method="GET", + params={"limit": limit, "offset": offset}, + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(FormList, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 409: - raise ConflictError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(FormList, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 409: + raise ConflictError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -454,11 +398,21 @@ async def get(self, form_id: str, *, request_options: typing.Optional[RequestOpt """ Get information about a given form

Required scope | `forms:read` - Parameters: - - form_id: str. Unique identifier for a Form + Parameters + ---------- + form_id : str + Unique identifier for a Form + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Returns + ------- + Form + Request was successful + + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -469,38 +423,23 @@ async def get(self, form_id: str, *, request_options: typing.Optional[RequestOpt ) """ _response = await self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"forms/{jsonable_encoder(form_id)}"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"forms/{jsonable_encoder(form_id)}", method="GET", request_options=request_options ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Form, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(Form, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -512,11 +451,21 @@ async def list_submissions( """ List form submissions for a given form

Required scope | `forms:read` - Parameters: - - form_id: str. Unique identifier for a Form + Parameters + ---------- + form_id : str + Unique identifier for a Form + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Returns + ------- + FormSubmissionList + Request was successful + + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -527,40 +476,23 @@ async def list_submissions( ) """ _response = await self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"forms/{jsonable_encoder(form_id)}/submissions" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"forms/{jsonable_encoder(form_id)}/submissions", method="GET", request_options=request_options ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(FormSubmissionList, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(FormSubmissionList, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -572,11 +504,21 @@ async def get_submission( """ Get information about a given form submission

Required scope | `forms:read` - Parameters: - - form_submission_id: str. Unique identifier for a Form Submission + Parameters + ---------- + form_submission_id : str + Unique identifier for a Form Submission + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + FormSubmission + Request was successful - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -587,40 +529,23 @@ async def get_submission( ) """ _response = await self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"form_submissions/{jsonable_encoder(form_submission_id)}" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"form_submissions/{jsonable_encoder(form_submission_id)}", method="GET", request_options=request_options ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(FormSubmission, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(FormSubmission, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -636,13 +561,24 @@ async def update_submission( """ Update hidden fields on a form submission

Required scope | `forms:write` - Parameters: - - form_submission_id: str. Unique identifier for a Form Submission + Parameters + ---------- + form_submission_id : str + Unique identifier for a Form Submission + + form_submission_data : typing.Optional[typing.Dict[str, typing.Any]] + An existing **hidden field** defined on the form schema, and the corresponding value to set + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - form_submission_data: typing.Optional[typing.Dict[str, typing.Any]]. An existing **hidden field** defined on the form schema, and the corresponding value to set + Returns + ------- + FormSubmission + Request was successful - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -652,52 +588,30 @@ async def update_submission( form_submission_id="form_submission_id", ) """ - _request: typing.Dict[str, typing.Any] = {} - if form_submission_data is not OMIT: - _request["formSubmissionData"] = form_submission_data _response = await self._client_wrapper.httpx_client.request( - "PATCH", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"form_submissions/{jsonable_encoder(form_submission_id)}" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"form_submissions/{jsonable_encoder(form_submission_id)}", + method="PATCH", + json={"formSubmissionData": form_submission_data}, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(FormSubmission, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 409: - raise ConflictError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(FormSubmission, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 409: + raise ConflictError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/src/webflow/resources/inventory/client.py b/src/webflow/resources/inventory/client.py index 9b9589a..44e16ea 100644 --- a/src/webflow/resources/inventory/client.py +++ b/src/webflow/resources/inventory/client.py @@ -1,13 +1,12 @@ # This file was auto-generated by Fern from our API Definition. import typing -import urllib.parse from json.decoder import JSONDecodeError from ...core.api_error import ApiError from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ...core.jsonable_encoder import jsonable_encoder -from ...core.remove_none_from_dict import remove_none_from_dict +from ...core.pydantic_utilities import pydantic_v1 from ...core.request_options import RequestOptions from ...errors.bad_request_error import BadRequestError from ...errors.conflict_error import ConflictError @@ -19,11 +18,6 @@ from ...types.inventory_item import InventoryItem from .types.inventory_update_request_inventory_type import InventoryUpdateRequestInventoryType -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -40,13 +34,24 @@ def list( Required scope | `ecommerce:read` - Parameters: - - collection_id: str. Unique identifier for a Collection + Parameters + ---------- + collection_id : str + Unique identifier for a Collection + + item_id : str + Unique identifier for an Item + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - item_id: str. Unique identifier for an Item + Returns + ------- + InventoryItem + Request was successful - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -58,43 +63,27 @@ def list( ) """ _response = self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"collections/{jsonable_encoder(collection_id)}/items/{jsonable_encoder(item_id)}/inventory", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"collections/{jsonable_encoder(collection_id)}/items/{jsonable_encoder(item_id)}/inventory", + method="GET", + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(InventoryItem, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 409: - raise ConflictError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(InventoryItem, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 409: + raise ConflictError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -115,19 +104,33 @@ def update( Required scope | `ecommerce:write` - Parameters: - - collection_id: str. Unique identifier for a Collection + Parameters + ---------- + collection_id : str + Unique identifier for a Collection + + item_id : str + Unique identifier for an Item + + inventory_type : InventoryUpdateRequestInventoryType + infinite or finite - - item_id: str. Unique identifier for an Item + update_quantity : typing.Optional[float] + Adds this quantity to currently store quantity. Can be negative. - - inventory_type: InventoryUpdateRequestInventoryType. infinite or finite + quantity : typing.Optional[float] + Immediately sets quantity to this value. - - update_quantity: typing.Optional[float]. Adds this quantity to currently store quantity. Can be negative. + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - quantity: typing.Optional[float]. Immediately sets quantity to this value. + Returns + ------- + InventoryItem + Request was successful - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow import InventoryUpdateRequestInventoryType from webflow.client import Webflow @@ -138,59 +141,32 @@ def update( collection_id="collection_id", item_id="item_id", inventory_type=InventoryUpdateRequestInventoryType.INFINITE, - update_quantity=1.0, - quantity=100.0, ) """ - _request: typing.Dict[str, typing.Any] = {"inventoryType": inventory_type} - if update_quantity is not OMIT: - _request["updateQuantity"] = update_quantity - if quantity is not OMIT: - _request["quantity"] = quantity _response = self._client_wrapper.httpx_client.request( - "PATCH", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"collections/{jsonable_encoder(collection_id)}/items/{jsonable_encoder(item_id)}/inventory", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"collections/{jsonable_encoder(collection_id)}/items/{jsonable_encoder(item_id)}/inventory", + method="PATCH", + json={"inventoryType": inventory_type, "updateQuantity": update_quantity, "quantity": quantity}, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(InventoryItem, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 409: - raise ConflictError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(InventoryItem, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 409: + raise ConflictError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -209,13 +185,24 @@ async def list( Required scope | `ecommerce:read` - Parameters: - - collection_id: str. Unique identifier for a Collection + Parameters + ---------- + collection_id : str + Unique identifier for a Collection - - item_id: str. Unique identifier for an Item + item_id : str + Unique identifier for an Item - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + InventoryItem + Request was successful + + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -227,43 +214,27 @@ async def list( ) """ _response = await self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"collections/{jsonable_encoder(collection_id)}/items/{jsonable_encoder(item_id)}/inventory", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"collections/{jsonable_encoder(collection_id)}/items/{jsonable_encoder(item_id)}/inventory", + method="GET", + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(InventoryItem, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 409: - raise ConflictError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(InventoryItem, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 409: + raise ConflictError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -284,19 +255,33 @@ async def update( Required scope | `ecommerce:write` - Parameters: - - collection_id: str. Unique identifier for a Collection + Parameters + ---------- + collection_id : str + Unique identifier for a Collection + + item_id : str + Unique identifier for an Item + + inventory_type : InventoryUpdateRequestInventoryType + infinite or finite - - item_id: str. Unique identifier for an Item + update_quantity : typing.Optional[float] + Adds this quantity to currently store quantity. Can be negative. - - inventory_type: InventoryUpdateRequestInventoryType. infinite or finite + quantity : typing.Optional[float] + Immediately sets quantity to this value. - - update_quantity: typing.Optional[float]. Adds this quantity to currently store quantity. Can be negative. + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - quantity: typing.Optional[float]. Immediately sets quantity to this value. + Returns + ------- + InventoryItem + Request was successful - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow import InventoryUpdateRequestInventoryType from webflow.client import AsyncWebflow @@ -307,59 +292,32 @@ async def update( collection_id="collection_id", item_id="item_id", inventory_type=InventoryUpdateRequestInventoryType.INFINITE, - update_quantity=1.0, - quantity=100.0, ) """ - _request: typing.Dict[str, typing.Any] = {"inventoryType": inventory_type} - if update_quantity is not OMIT: - _request["updateQuantity"] = update_quantity - if quantity is not OMIT: - _request["quantity"] = quantity _response = await self._client_wrapper.httpx_client.request( - "PATCH", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"collections/{jsonable_encoder(collection_id)}/items/{jsonable_encoder(item_id)}/inventory", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"collections/{jsonable_encoder(collection_id)}/items/{jsonable_encoder(item_id)}/inventory", + method="PATCH", + json={"inventoryType": inventory_type, "updateQuantity": update_quantity, "quantity": quantity}, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(InventoryItem, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 409: - raise ConflictError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(InventoryItem, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 409: + raise ConflictError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/src/webflow/resources/orders/__init__.py b/src/webflow/resources/orders/__init__.py index 94cbc01..7076133 100644 --- a/src/webflow/resources/orders/__init__.py +++ b/src/webflow/resources/orders/__init__.py @@ -1,5 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -from .types import OrdersRefundRequestReason +from .types import OrdersListRequestStatus, OrdersRefundRequestReason -__all__ = ["OrdersRefundRequestReason"] +__all__ = ["OrdersListRequestStatus", "OrdersRefundRequestReason"] diff --git a/src/webflow/resources/orders/client.py b/src/webflow/resources/orders/client.py index 3c079cb..21dc5e8 100644 --- a/src/webflow/resources/orders/client.py +++ b/src/webflow/resources/orders/client.py @@ -1,13 +1,12 @@ # This file was auto-generated by Fern from our API Definition. import typing -import urllib.parse from json.decoder import JSONDecodeError from ...core.api_error import ApiError from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ...core.jsonable_encoder import jsonable_encoder -from ...core.remove_none_from_dict import remove_none_from_dict +from ...core.pydantic_utilities import pydantic_v1 from ...core.request_options import RequestOptions from ...errors.bad_request_error import BadRequestError from ...errors.conflict_error import ConflictError @@ -18,13 +17,9 @@ from ...errors.unauthorized_error import UnauthorizedError from ...types.order import Order from ...types.order_list import OrderList +from .types.orders_list_request_status import OrdersListRequestStatus from .types.orders_refund_request_reason import OrdersRefundRequestReason -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -37,7 +32,7 @@ def list( self, site_id: str, *, - status: typing.Optional[str] = None, + status: typing.Optional[OrdersListRequestStatus] = None, offset: typing.Optional[float] = None, limit: typing.Optional[float] = None, request_options: typing.Optional[RequestOptions] = None, @@ -47,17 +42,30 @@ def list( Required scope | `ecommerce:read` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site + + status : typing.Optional[OrdersListRequestStatus] + Filter the orders by status - - status: typing.Optional[str]. Filter the orders by status + offset : typing.Optional[float] + Offset used for pagination if the results have more than limit records - - offset: typing.Optional[float]. Offset used for pagination if the results have more than limit records + limit : typing.Optional[float] + Maximum number of records to be returned (max limit: 100) - - limit: typing.Optional[float]. Maximum number of records to be returned (max limit: 100) + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Returns + ------- + OrderList + Request was successful + + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -68,53 +76,28 @@ def list( ) """ _response = self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/orders" - ), - params=jsonable_encoder( - remove_none_from_dict( - { - "status": status, - "offset": offset, - "limit": limit, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/orders", + method="GET", + params={"status": status, "offset": offset, "limit": limit}, + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(OrderList, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 409: - raise ConflictError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(OrderList, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 409: + raise ConflictError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -126,13 +109,24 @@ def get(self, site_id: str, order_id: str, *, request_options: typing.Optional[R Required scope | `ecommerce:read` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site + + order_id : str + Unique identifier for an Order - - order_id: str. Unique identifier for an Order + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Returns + ------- + Order + Request was successful + + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -144,43 +138,27 @@ def get(self, site_id: str, order_id: str, *, request_options: typing.Optional[R ) """ _response = self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"sites/{jsonable_encoder(site_id)}/orders/{jsonable_encoder(order_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/orders/{jsonable_encoder(order_id)}", + method="GET", + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Order, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 409: - raise ConflictError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(Order, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 409: + raise ConflictError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -202,21 +180,36 @@ def update( Required scope | `ecommerce:write` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site + + order_id : str + Unique identifier for an Order - - order_id: str. Unique identifier for an Order + comment : typing.Optional[str] + Arbitrary data for your records - - comment: typing.Optional[str]. Arbitrary data for your records + shipping_provider : typing.Optional[str] + Company or method used to ship order - - shipping_provider: typing.Optional[str]. Company or method used to ship order + shipping_tracking : typing.Optional[str] + Tracking number for order shipment - - shipping_tracking: typing.Optional[str]. Tracking number for order shipment + shipping_tracking_url : typing.Optional[str] + URL to track order shipment - - shipping_tracking_url: typing.Optional[str]. URL to track order shipment + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Returns + ------- + Order + Request was successful + + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -225,65 +218,37 @@ def update( client.orders.update( site_id="site_id", order_id="order_id", - comment="Example comment to myself", - shipping_provider="Shipping Company, Co.", - shipping_tracking="tr00000000001", - shipping_tracking_url="https://www.shippingcompany.com/tracking/tr00000000001", ) """ - _request: typing.Dict[str, typing.Any] = {} - if comment is not OMIT: - _request["comment"] = comment - if shipping_provider is not OMIT: - _request["shippingProvider"] = shipping_provider - if shipping_tracking is not OMIT: - _request["shippingTracking"] = shipping_tracking - if shipping_tracking_url is not OMIT: - _request["shippingTrackingURL"] = shipping_tracking_url _response = self._client_wrapper.httpx_client.request( - "PATCH", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"sites/{jsonable_encoder(site_id)}/orders/{jsonable_encoder(order_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + f"sites/{jsonable_encoder(site_id)}/orders/{jsonable_encoder(order_id)}", + method="PATCH", + json={ + "comment": comment, + "shippingProvider": shipping_provider, + "shippingTracking": shipping_tracking, + "shippingTrackingURL": shipping_tracking_url, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Order, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 409: - raise ConflictError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(Order, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 409: + raise ConflictError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -302,15 +267,27 @@ def update_fulfill( Required scope | `ecommerce:write` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site + + order_id : str + Unique identifier for an Order - - order_id: str. Unique identifier for an Order + send_order_fulfilled_email : typing.Optional[bool] + Whether or not the Order Fulfilled email should be sent - - send_order_fulfilled_email: typing.Optional[bool]. Whether or not the Order Fulfilled email should be sent + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Returns + ------- + Order + Request was successful + + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -321,53 +298,30 @@ def update_fulfill( order_id="order_id", ) """ - _request: typing.Dict[str, typing.Any] = {} - if send_order_fulfilled_email is not OMIT: - _request["sendOrderFulfilledEmail"] = send_order_fulfilled_email _response = self._client_wrapper.httpx_client.request( - "POST", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"sites/{jsonable_encoder(site_id)}/orders/{jsonable_encoder(order_id)}/fulfill", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/orders/{jsonable_encoder(order_id)}/fulfill", + method="POST", + json={"sendOrderFulfilledEmail": send_order_fulfilled_email}, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Order, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 409: - raise ConflictError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(Order, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 409: + raise ConflictError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -381,13 +335,24 @@ def update_unfulfill( Required scope | `ecommerce:write` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site + + order_id : str + Unique identifier for an Order + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - order_id: str. Unique identifier for an Order + Returns + ------- + Order + Request was successful - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -399,46 +364,27 @@ def update_unfulfill( ) """ _response = self._client_wrapper.httpx_client.request( - "POST", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"sites/{jsonable_encoder(site_id)}/orders/{jsonable_encoder(order_id)}/unfulfill", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) - if request_options is not None - else None, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/orders/{jsonable_encoder(order_id)}/unfulfill", + method="POST", + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Order, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 409: - raise ConflictError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(Order, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 409: + raise ConflictError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -458,15 +404,27 @@ def refund( Required scope | `ecommerce:write` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site - - order_id: str. Unique identifier for an Order + order_id : str + Unique identifier for an Order - - reason: typing.Optional[OrdersRefundRequestReason]. The reason for the refund + reason : typing.Optional[OrdersRefundRequestReason] + The reason for the refund - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + Order + Request was successful + + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -477,53 +435,30 @@ def refund( order_id="order_id", ) """ - _request: typing.Dict[str, typing.Any] = {} - if reason is not OMIT: - _request["reason"] = reason.value if reason is not None else None _response = self._client_wrapper.httpx_client.request( - "POST", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"sites/{jsonable_encoder(site_id)}/orders/{jsonable_encoder(order_id)}/refund", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/orders/{jsonable_encoder(order_id)}/refund", + method="POST", + json={"reason": reason}, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Order, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 409: - raise ConflictError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(Order, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 409: + raise ConflictError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -538,7 +473,7 @@ async def list( self, site_id: str, *, - status: typing.Optional[str] = None, + status: typing.Optional[OrdersListRequestStatus] = None, offset: typing.Optional[float] = None, limit: typing.Optional[float] = None, request_options: typing.Optional[RequestOptions] = None, @@ -548,17 +483,30 @@ async def list( Required scope | `ecommerce:read` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site - - status: typing.Optional[str]. Filter the orders by status + status : typing.Optional[OrdersListRequestStatus] + Filter the orders by status - - offset: typing.Optional[float]. Offset used for pagination if the results have more than limit records + offset : typing.Optional[float] + Offset used for pagination if the results have more than limit records - - limit: typing.Optional[float]. Maximum number of records to be returned (max limit: 100) + limit : typing.Optional[float] + Maximum number of records to be returned (max limit: 100) - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + OrderList + Request was successful + + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -569,53 +517,28 @@ async def list( ) """ _response = await self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/orders" - ), - params=jsonable_encoder( - remove_none_from_dict( - { - "status": status, - "offset": offset, - "limit": limit, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/orders", + method="GET", + params={"status": status, "offset": offset, "limit": limit}, + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(OrderList, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 409: - raise ConflictError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(OrderList, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 409: + raise ConflictError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -629,13 +552,24 @@ async def get( Required scope | `ecommerce:read` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site + + order_id : str + Unique identifier for an Order + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - order_id: str. Unique identifier for an Order + Returns + ------- + Order + Request was successful - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -647,43 +581,27 @@ async def get( ) """ _response = await self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"sites/{jsonable_encoder(site_id)}/orders/{jsonable_encoder(order_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/orders/{jsonable_encoder(order_id)}", + method="GET", + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Order, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 409: - raise ConflictError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(Order, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 409: + raise ConflictError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -705,21 +623,36 @@ async def update( Required scope | `ecommerce:write` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site - - order_id: str. Unique identifier for an Order + order_id : str + Unique identifier for an Order - - comment: typing.Optional[str]. Arbitrary data for your records + comment : typing.Optional[str] + Arbitrary data for your records - - shipping_provider: typing.Optional[str]. Company or method used to ship order + shipping_provider : typing.Optional[str] + Company or method used to ship order - - shipping_tracking: typing.Optional[str]. Tracking number for order shipment + shipping_tracking : typing.Optional[str] + Tracking number for order shipment - - shipping_tracking_url: typing.Optional[str]. URL to track order shipment + shipping_tracking_url : typing.Optional[str] + URL to track order shipment - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + Order + Request was successful + + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -728,65 +661,37 @@ async def update( await client.orders.update( site_id="site_id", order_id="order_id", - comment="Example comment to myself", - shipping_provider="Shipping Company, Co.", - shipping_tracking="tr00000000001", - shipping_tracking_url="https://www.shippingcompany.com/tracking/tr00000000001", ) """ - _request: typing.Dict[str, typing.Any] = {} - if comment is not OMIT: - _request["comment"] = comment - if shipping_provider is not OMIT: - _request["shippingProvider"] = shipping_provider - if shipping_tracking is not OMIT: - _request["shippingTracking"] = shipping_tracking - if shipping_tracking_url is not OMIT: - _request["shippingTrackingURL"] = shipping_tracking_url _response = await self._client_wrapper.httpx_client.request( - "PATCH", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"sites/{jsonable_encoder(site_id)}/orders/{jsonable_encoder(order_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + f"sites/{jsonable_encoder(site_id)}/orders/{jsonable_encoder(order_id)}", + method="PATCH", + json={ + "comment": comment, + "shippingProvider": shipping_provider, + "shippingTracking": shipping_tracking, + "shippingTrackingURL": shipping_tracking_url, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Order, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 409: - raise ConflictError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(Order, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 409: + raise ConflictError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -805,15 +710,27 @@ async def update_fulfill( Required scope | `ecommerce:write` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site + + order_id : str + Unique identifier for an Order - - order_id: str. Unique identifier for an Order + send_order_fulfilled_email : typing.Optional[bool] + Whether or not the Order Fulfilled email should be sent - - send_order_fulfilled_email: typing.Optional[bool]. Whether or not the Order Fulfilled email should be sent + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Returns + ------- + Order + Request was successful + + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -824,53 +741,30 @@ async def update_fulfill( order_id="order_id", ) """ - _request: typing.Dict[str, typing.Any] = {} - if send_order_fulfilled_email is not OMIT: - _request["sendOrderFulfilledEmail"] = send_order_fulfilled_email _response = await self._client_wrapper.httpx_client.request( - "POST", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"sites/{jsonable_encoder(site_id)}/orders/{jsonable_encoder(order_id)}/fulfill", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/orders/{jsonable_encoder(order_id)}/fulfill", + method="POST", + json={"sendOrderFulfilledEmail": send_order_fulfilled_email}, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Order, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 409: - raise ConflictError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(Order, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 409: + raise ConflictError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -884,13 +778,24 @@ async def update_unfulfill( Required scope | `ecommerce:write` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site + + order_id : str + Unique identifier for an Order + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - order_id: str. Unique identifier for an Order + Returns + ------- + Order + Request was successful - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -902,46 +807,27 @@ async def update_unfulfill( ) """ _response = await self._client_wrapper.httpx_client.request( - "POST", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"sites/{jsonable_encoder(site_id)}/orders/{jsonable_encoder(order_id)}/unfulfill", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) - if request_options is not None - else None, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/orders/{jsonable_encoder(order_id)}/unfulfill", + method="POST", + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Order, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 409: - raise ConflictError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(Order, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 409: + raise ConflictError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -961,15 +847,27 @@ async def refund( Required scope | `ecommerce:write` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site - - order_id: str. Unique identifier for an Order + order_id : str + Unique identifier for an Order - - reason: typing.Optional[OrdersRefundRequestReason]. The reason for the refund + reason : typing.Optional[OrdersRefundRequestReason] + The reason for the refund - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + Order + Request was successful + + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -980,53 +878,30 @@ async def refund( order_id="order_id", ) """ - _request: typing.Dict[str, typing.Any] = {} - if reason is not OMIT: - _request["reason"] = reason.value if reason is not None else None _response = await self._client_wrapper.httpx_client.request( - "POST", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"sites/{jsonable_encoder(site_id)}/orders/{jsonable_encoder(order_id)}/refund", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/orders/{jsonable_encoder(order_id)}/refund", + method="POST", + json={"reason": reason}, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Order, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 409: - raise ConflictError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(Order, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 409: + raise ConflictError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/src/webflow/resources/orders/types/__init__.py b/src/webflow/resources/orders/types/__init__.py index a219c24..7df0fa1 100644 --- a/src/webflow/resources/orders/types/__init__.py +++ b/src/webflow/resources/orders/types/__init__.py @@ -1,5 +1,6 @@ # This file was auto-generated by Fern from our API Definition. +from .orders_list_request_status import OrdersListRequestStatus from .orders_refund_request_reason import OrdersRefundRequestReason -__all__ = ["OrdersRefundRequestReason"] +__all__ = ["OrdersListRequestStatus", "OrdersRefundRequestReason"] diff --git a/src/webflow/resources/orders/types/orders_list_request_status.py b/src/webflow/resources/orders/types/orders_list_request_status.py new file mode 100644 index 0000000..ecdfbca --- /dev/null +++ b/src/webflow/resources/orders/types/orders_list_request_status.py @@ -0,0 +1,37 @@ +# This file was auto-generated by Fern from our API Definition. + +import enum +import typing + +T_Result = typing.TypeVar("T_Result") + + +class OrdersListRequestStatus(str, enum.Enum): + PENDING = "pending" + REFUNDED = "refunded" + DISPUTE_LOST = "dispute-lost" + FULFILLED = "fulfilled" + DISPUTED = "disputed" + UNFULFILLED = "unfulfilled" + + def visit( + self, + pending: typing.Callable[[], T_Result], + refunded: typing.Callable[[], T_Result], + dispute_lost: typing.Callable[[], T_Result], + fulfilled: typing.Callable[[], T_Result], + disputed: typing.Callable[[], T_Result], + unfulfilled: typing.Callable[[], T_Result], + ) -> T_Result: + if self is OrdersListRequestStatus.PENDING: + return pending() + if self is OrdersListRequestStatus.REFUNDED: + return refunded() + if self is OrdersListRequestStatus.DISPUTE_LOST: + return dispute_lost() + if self is OrdersListRequestStatus.FULFILLED: + return fulfilled() + if self is OrdersListRequestStatus.DISPUTED: + return disputed() + if self is OrdersListRequestStatus.UNFULFILLED: + return unfulfilled() diff --git a/src/webflow/resources/pages/__init__.py b/src/webflow/resources/pages/__init__.py index 58f0629..b846071 100644 --- a/src/webflow/resources/pages/__init__.py +++ b/src/webflow/resources/pages/__init__.py @@ -1,6 +1,6 @@ # This file was auto-generated by Fern from our API Definition. -from .types import DomWriteNodesItem +from .types import DomWriteNodesItem, UpdateStaticContentResponse from .resources import scripts -__all__ = ["DomWriteNodesItem", "scripts"] +__all__ = ["DomWriteNodesItem", "UpdateStaticContentResponse", "scripts"] diff --git a/src/webflow/resources/pages/client.py b/src/webflow/resources/pages/client.py index 8b3b1f6..61c1550 100644 --- a/src/webflow/resources/pages/client.py +++ b/src/webflow/resources/pages/client.py @@ -1,13 +1,13 @@ # This file was auto-generated by Fern from our API Definition. +import datetime as dt import typing -import urllib.parse from json.decoder import JSONDecodeError from ...core.api_error import ApiError from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ...core.jsonable_encoder import jsonable_encoder -from ...core.remove_none_from_dict import remove_none_from_dict +from ...core.pydantic_utilities import pydantic_v1 from ...core.request_options import RequestOptions from ...errors.bad_request_error import BadRequestError from ...errors.forbidden_error import ForbiddenError @@ -16,15 +16,13 @@ from ...errors.too_many_requests_error import TooManyRequestsError from ...errors.unauthorized_error import UnauthorizedError from ...types.dom import Dom -from ...types.page import Page +from ...types.page_details import PageDetails from ...types.page_list import PageList +from ...types.page_open_graph import PageOpenGraph +from ...types.page_seo import PageSeo from .resources.scripts.client import AsyncScriptsClient, ScriptsClient from .types.dom_write_nodes_item import DomWriteNodesItem - -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore +from .types.update_static_content_response import UpdateStaticContentResponse # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -47,17 +45,30 @@ def list( """ List of all pages for a site

Required scope | `pages:read` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site + + locale : typing.Optional[str] + Unique identifier for a specific locale. Applicable, when using localization. - - locale: typing.Optional[str]. Unique identifier for a specific locale. Applicable, when using localization. + limit : typing.Optional[float] + Maximum number of records to be returned (max limit: 100) - - limit: typing.Optional[float]. Maximum number of records to be returned (max limit: 100) + offset : typing.Optional[float] + Offset used for pagination if the results have more than limit records - - offset: typing.Optional[float]. Offset used for pagination if the results have more than limit records + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Returns + ------- + PageList + Request was successful + + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -68,47 +79,24 @@ def list( ) """ _response = self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/pages"), - params=jsonable_encoder( - remove_none_from_dict( - { - "locale": locale, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/pages", + method="GET", + params={"locale": locale, "limit": limit, "offset": offset}, + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(PageList, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(PageList, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -120,17 +108,28 @@ def get_metadata( *, locale: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None, - ) -> Page: + ) -> PageDetails: """ Get metadata information for a single page

Required scope | `pages:read` - Parameters: - - page_id: str. Unique identifier for a Page + Parameters + ---------- + page_id : str + Unique identifier for a Page + + locale : typing.Optional[str] + Unique identifier for a specific locale. Applicable, when using localization. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - locale: typing.Optional[str]. Unique identifier for a specific locale. Applicable, when using localization. + Returns + ------- + PageDetails + Request was successful - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -141,45 +140,24 @@ def get_metadata( ) """ _response = self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"pages/{jsonable_encoder(page_id)}"), - params=jsonable_encoder( - remove_none_from_dict( - { - "locale": locale, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"pages/{jsonable_encoder(page_id)}", + method="GET", + params={"locale": locale}, + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Page, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(PageDetails, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -190,24 +168,88 @@ def update_page_settings( page_id: str, *, locale: typing.Optional[str] = None, - request: Page, + id: typing.Optional[str] = OMIT, + site_id: typing.Optional[str] = OMIT, + title: typing.Optional[str] = OMIT, + slug: typing.Optional[str] = OMIT, + parent_id: typing.Optional[str] = OMIT, + collection_id: typing.Optional[str] = OMIT, + created_on: typing.Optional[dt.datetime] = OMIT, + last_updated: typing.Optional[dt.datetime] = OMIT, + archived: typing.Optional[bool] = OMIT, + draft: typing.Optional[bool] = OMIT, + can_branch: typing.Optional[bool] = OMIT, + is_members_only: typing.Optional[bool] = OMIT, + seo: typing.Optional[PageSeo] = OMIT, + open_graph: typing.Optional[PageOpenGraph] = OMIT, request_options: typing.Optional[RequestOptions] = None, - ) -> Page: + ) -> PageDetails: """ Update Page-level metadata, including SEO and Open Graph fields.

Required scope | `pages:write` - Parameters: - - page_id: str. Unique identifier for a Page + Parameters + ---------- + page_id : str + Unique identifier for a Page + + locale : typing.Optional[str] + Unique identifier for a specific locale. Applicable, when using localization. + + id : typing.Optional[str] + Unique identifier for the Page + + site_id : typing.Optional[str] + Unique identifier for the Site + + title : typing.Optional[str] + Title of the Page - - locale: typing.Optional[str]. Unique identifier for a specific locale. Applicable, when using localization. + slug : typing.Optional[str] + slug of the Page (derived from title) - - request: Page. + parent_id : typing.Optional[str] + Identifier of the parent folder - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + collection_id : typing.Optional[str] + Unique identifier for a linked Collection, value will be null if the Page is not part of a Collection. + + created_on : typing.Optional[dt.datetime] + The date the Page was created + + last_updated : typing.Optional[dt.datetime] + The date the Page was most recently updated + + archived : typing.Optional[bool] + Whether the Page has been archived + + draft : typing.Optional[bool] + Whether the Page is a draft + + can_branch : typing.Optional[bool] + Indicates whether the Page supports [Page Branching](https://university.webflow.com/lesson/page-branching) + + is_members_only : typing.Optional[bool] + Indicates whether the Page is restricted by [Memberships Controls](https://university.webflow.com/lesson/webflow-memberships-overview#how-to-manage-page-restrictions) + + seo : typing.Optional[PageSeo] + SEO-related fields for the Page + + open_graph : typing.Optional[PageOpenGraph] + Open Graph fields for the Page + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + PageDetails + Request was successful + + Examples + -------- import datetime - from webflow import Page, PageOpenGraph, PageSeo + from webflow import PageOpenGraph, PageSeo from webflow.client import Webflow client = Webflow( @@ -215,82 +257,69 @@ def update_page_settings( ) client.pages.update_page_settings( page_id="page_id", - request=Page( - id="6390c49774a71f0e3c1a08ee", - site_id="6390c49674a71f84b51a08d8", - title="Blog Categories Template", - slug="detail_blog-category", - parent_id="6419db964a9c435aa3af6251", - collection_id="6390c49774a71f12831a08e3", - created_on=datetime.datetime.fromisoformat( - "2018-10-14 21:55:49+00:00", - ), - last_updated=datetime.datetime.fromisoformat( - "2022-12-07 16:51:37+00:00", - ), - archived=False, - draft=False, - can_branch=True, - is_members_only=False, - seo=PageSeo( - title="CoffeeStyle eCommerce - Webflow HTML website template", - description="This Webflow template offers a quick start into an e-commerce / memberships site", - ), - open_graph=PageOpenGraph( - title="CoffeeStyle eCommerce - Webflow HTML website template", - title_copied=True, - description="This Webflow template offers a quick start into an e-commerce / memberships site", - description_copied=True, - ), + id="6596da6045e56dee495bcbba", + site_id="6258612d1ee792848f805dcf", + title="Guide to the Galaxy", + slug="guide-to-the-galaxy", + parent_id="6419db964a9c435aa3af6251", + collection_id="6390c49774a71f12831a08e3", + created_on=datetime.datetime.fromisoformat( + "2024-03-11 10:42:00+00:00", + ), + last_updated=datetime.datetime.fromisoformat( + "2024-03-11 10:42:42+00:00", + ), + archived=False, + draft=False, + can_branch=True, + seo=PageSeo( + title="The Ultimate Hitchhiker's Guide to the Galaxy", + description="Everything you need to know about the galaxy, from avoiding Vogon poetry to the importance of towels.", + ), + open_graph=PageOpenGraph( + title="Explore the Cosmos with The Ultimate Guide", + title_copied=False, + description="Dive deep into the mysteries of the universe with your guide to everything galactic.", + description_copied=False, ), ) """ _response = self._client_wrapper.httpx_client.request( - "PUT", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"pages/{jsonable_encoder(page_id)}"), - params=jsonable_encoder( - remove_none_from_dict( - { - "locale": locale, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + f"pages/{jsonable_encoder(page_id)}", + method="PUT", + params={"locale": locale}, + json={ + "id": id, + "siteId": site_id, + "title": title, + "slug": slug, + "parentId": parent_id, + "collectionId": collection_id, + "createdOn": created_on, + "lastUpdated": last_updated, + "archived": archived, + "draft": draft, + "canBranch": can_branch, + "isMembersOnly": is_members_only, + "seo": seo, + "openGraph": open_graph, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Page, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(PageDetails, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -301,18 +330,37 @@ def get_content( page_id: str, *, locale: typing.Optional[str] = None, + limit: typing.Optional[float] = None, + offset: typing.Optional[float] = None, request_options: typing.Optional[RequestOptions] = None, ) -> Dom: """ Get static content from a static page.
If you do not provide a Locale ID in your request, the response will return any content that can be localized from the Primary locale

Required scope | `pages:read` - Parameters: - - page_id: str. Unique identifier for a Page + Parameters + ---------- + page_id : str + Unique identifier for a Page + + locale : typing.Optional[str] + Unique identifier for a specific locale. Applicable, when using localization. + + limit : typing.Optional[float] + Maximum number of records to be returned (max limit: 100) + + offset : typing.Optional[float] + Offset used for pagination if the results have more than limit records + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - locale: typing.Optional[str]. Unique identifier for a specific locale. Applicable, when using localization. + Returns + ------- + Dom + Request was successful - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -323,47 +371,26 @@ def get_content( ) """ _response = self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"pages/{jsonable_encoder(page_id)}/dom"), - params=jsonable_encoder( - remove_none_from_dict( - { - "locale": locale, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"pages/{jsonable_encoder(page_id)}/dom", + method="GET", + params={"locale": locale, "limit": limit, "offset": offset}, + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Dom, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(Dom, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -376,19 +403,30 @@ def update_static_content( locale: str, nodes: typing.Sequence[DomWriteNodesItem], request_options: typing.Optional[RequestOptions] = None, - ) -> Dom: + ) -> UpdateStaticContentResponse: """ Update static content on a static page. This endpoint supports sending 1000 nodes per request.

Required scope | `pages:write` - Parameters: - - page_id: str. Unique identifier for a Page + Parameters + ---------- + page_id : str + Unique identifier for a Page + + locale : str + The locale identifier. - - locale: str. The locale identifier. + nodes : typing.Sequence[DomWriteNodesItem] - - nodes: typing.Sequence[DomWriteNodesItem]. + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Returns + ------- + UpdateStaticContentResponse + Request was successful + + Examples + -------- from webflow import DomWriteNodesItem from webflow.client import Webflow @@ -400,60 +438,43 @@ def update_static_content( locale="locale", nodes=[ DomWriteNodesItem( - node_id="guide-title-id", - text="

Hello world

", - ) + node_id="a245c12d-995b-55ee-5ec7-aa36a6cad623", + text="

The Hitchhiker's Guide to the Galaxy

", + ), + DomWriteNodesItem( + node_id="a245c12d-995b-55ee-5ec7-aa36a6cad627", + text="

Don't Panic!

Always know where your towel is.

", + ), + DomWriteNodesItem( + node_id="a245c12d-995b-55ee-5ec7-aa36a6cad629", + text="Marvin, the Paranoid Android", + ), ], ) """ _response = self._client_wrapper.httpx_client.request( - "POST", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"pages/{jsonable_encoder(page_id)}/dom"), - params=jsonable_encoder( - remove_none_from_dict( - { - "locale": locale, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - json=jsonable_encoder({"nodes": nodes}) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder({"nodes": nodes}), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"pages/{jsonable_encoder(page_id)}/dom", + method="POST", + params={"locale": locale}, + json={"nodes": nodes}, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Dom, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(UpdateStaticContentResponse, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -477,17 +498,30 @@ async def list( """ List of all pages for a site

Required scope | `pages:read` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site - - locale: typing.Optional[str]. Unique identifier for a specific locale. Applicable, when using localization. + locale : typing.Optional[str] + Unique identifier for a specific locale. Applicable, when using localization. - - limit: typing.Optional[float]. Maximum number of records to be returned (max limit: 100) + limit : typing.Optional[float] + Maximum number of records to be returned (max limit: 100) - - offset: typing.Optional[float]. Offset used for pagination if the results have more than limit records + offset : typing.Optional[float] + Offset used for pagination if the results have more than limit records - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + PageList + Request was successful + + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -498,47 +532,24 @@ async def list( ) """ _response = await self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/pages"), - params=jsonable_encoder( - remove_none_from_dict( - { - "locale": locale, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/pages", + method="GET", + params={"locale": locale, "limit": limit, "offset": offset}, + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(PageList, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(PageList, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -550,17 +561,28 @@ async def get_metadata( *, locale: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None, - ) -> Page: + ) -> PageDetails: """ Get metadata information for a single page

Required scope | `pages:read` - Parameters: - - page_id: str. Unique identifier for a Page + Parameters + ---------- + page_id : str + Unique identifier for a Page - - locale: typing.Optional[str]. Unique identifier for a specific locale. Applicable, when using localization. + locale : typing.Optional[str] + Unique identifier for a specific locale. Applicable, when using localization. - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + PageDetails + Request was successful + + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -571,45 +593,24 @@ async def get_metadata( ) """ _response = await self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"pages/{jsonable_encoder(page_id)}"), - params=jsonable_encoder( - remove_none_from_dict( - { - "locale": locale, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"pages/{jsonable_encoder(page_id)}", + method="GET", + params={"locale": locale}, + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Page, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(PageDetails, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -620,24 +621,88 @@ async def update_page_settings( page_id: str, *, locale: typing.Optional[str] = None, - request: Page, + id: typing.Optional[str] = OMIT, + site_id: typing.Optional[str] = OMIT, + title: typing.Optional[str] = OMIT, + slug: typing.Optional[str] = OMIT, + parent_id: typing.Optional[str] = OMIT, + collection_id: typing.Optional[str] = OMIT, + created_on: typing.Optional[dt.datetime] = OMIT, + last_updated: typing.Optional[dt.datetime] = OMIT, + archived: typing.Optional[bool] = OMIT, + draft: typing.Optional[bool] = OMIT, + can_branch: typing.Optional[bool] = OMIT, + is_members_only: typing.Optional[bool] = OMIT, + seo: typing.Optional[PageSeo] = OMIT, + open_graph: typing.Optional[PageOpenGraph] = OMIT, request_options: typing.Optional[RequestOptions] = None, - ) -> Page: + ) -> PageDetails: """ Update Page-level metadata, including SEO and Open Graph fields.

Required scope | `pages:write` - Parameters: - - page_id: str. Unique identifier for a Page + Parameters + ---------- + page_id : str + Unique identifier for a Page + + locale : typing.Optional[str] + Unique identifier for a specific locale. Applicable, when using localization. + + id : typing.Optional[str] + Unique identifier for the Page + + site_id : typing.Optional[str] + Unique identifier for the Site + + title : typing.Optional[str] + Title of the Page + + slug : typing.Optional[str] + slug of the Page (derived from title) - - locale: typing.Optional[str]. Unique identifier for a specific locale. Applicable, when using localization. + parent_id : typing.Optional[str] + Identifier of the parent folder - - request: Page. + collection_id : typing.Optional[str] + Unique identifier for a linked Collection, value will be null if the Page is not part of a Collection. - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + created_on : typing.Optional[dt.datetime] + The date the Page was created + + last_updated : typing.Optional[dt.datetime] + The date the Page was most recently updated + + archived : typing.Optional[bool] + Whether the Page has been archived + + draft : typing.Optional[bool] + Whether the Page is a draft + + can_branch : typing.Optional[bool] + Indicates whether the Page supports [Page Branching](https://university.webflow.com/lesson/page-branching) + + is_members_only : typing.Optional[bool] + Indicates whether the Page is restricted by [Memberships Controls](https://university.webflow.com/lesson/webflow-memberships-overview#how-to-manage-page-restrictions) + + seo : typing.Optional[PageSeo] + SEO-related fields for the Page + + open_graph : typing.Optional[PageOpenGraph] + Open Graph fields for the Page + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + PageDetails + Request was successful + + Examples + -------- import datetime - from webflow import Page, PageOpenGraph, PageSeo + from webflow import PageOpenGraph, PageSeo from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -645,82 +710,69 @@ async def update_page_settings( ) await client.pages.update_page_settings( page_id="page_id", - request=Page( - id="6390c49774a71f0e3c1a08ee", - site_id="6390c49674a71f84b51a08d8", - title="Blog Categories Template", - slug="detail_blog-category", - parent_id="6419db964a9c435aa3af6251", - collection_id="6390c49774a71f12831a08e3", - created_on=datetime.datetime.fromisoformat( - "2018-10-14 21:55:49+00:00", - ), - last_updated=datetime.datetime.fromisoformat( - "2022-12-07 16:51:37+00:00", - ), - archived=False, - draft=False, - can_branch=True, - is_members_only=False, - seo=PageSeo( - title="CoffeeStyle eCommerce - Webflow HTML website template", - description="This Webflow template offers a quick start into an e-commerce / memberships site", - ), - open_graph=PageOpenGraph( - title="CoffeeStyle eCommerce - Webflow HTML website template", - title_copied=True, - description="This Webflow template offers a quick start into an e-commerce / memberships site", - description_copied=True, - ), + id="6596da6045e56dee495bcbba", + site_id="6258612d1ee792848f805dcf", + title="Guide to the Galaxy", + slug="guide-to-the-galaxy", + parent_id="6419db964a9c435aa3af6251", + collection_id="6390c49774a71f12831a08e3", + created_on=datetime.datetime.fromisoformat( + "2024-03-11 10:42:00+00:00", + ), + last_updated=datetime.datetime.fromisoformat( + "2024-03-11 10:42:42+00:00", + ), + archived=False, + draft=False, + can_branch=True, + seo=PageSeo( + title="The Ultimate Hitchhiker's Guide to the Galaxy", + description="Everything you need to know about the galaxy, from avoiding Vogon poetry to the importance of towels.", + ), + open_graph=PageOpenGraph( + title="Explore the Cosmos with The Ultimate Guide", + title_copied=False, + description="Dive deep into the mysteries of the universe with your guide to everything galactic.", + description_copied=False, ), ) """ _response = await self._client_wrapper.httpx_client.request( - "PUT", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"pages/{jsonable_encoder(page_id)}"), - params=jsonable_encoder( - remove_none_from_dict( - { - "locale": locale, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + f"pages/{jsonable_encoder(page_id)}", + method="PUT", + params={"locale": locale}, + json={ + "id": id, + "siteId": site_id, + "title": title, + "slug": slug, + "parentId": parent_id, + "collectionId": collection_id, + "createdOn": created_on, + "lastUpdated": last_updated, + "archived": archived, + "draft": draft, + "canBranch": can_branch, + "isMembersOnly": is_members_only, + "seo": seo, + "openGraph": open_graph, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Page, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(PageDetails, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -731,18 +783,37 @@ async def get_content( page_id: str, *, locale: typing.Optional[str] = None, + limit: typing.Optional[float] = None, + offset: typing.Optional[float] = None, request_options: typing.Optional[RequestOptions] = None, ) -> Dom: """ Get static content from a static page.
If you do not provide a Locale ID in your request, the response will return any content that can be localized from the Primary locale

Required scope | `pages:read` - Parameters: - - page_id: str. Unique identifier for a Page + Parameters + ---------- + page_id : str + Unique identifier for a Page + + locale : typing.Optional[str] + Unique identifier for a specific locale. Applicable, when using localization. + + limit : typing.Optional[float] + Maximum number of records to be returned (max limit: 100) - - locale: typing.Optional[str]. Unique identifier for a specific locale. Applicable, when using localization. + offset : typing.Optional[float] + Offset used for pagination if the results have more than limit records - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + Dom + Request was successful + + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -753,47 +824,26 @@ async def get_content( ) """ _response = await self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"pages/{jsonable_encoder(page_id)}/dom"), - params=jsonable_encoder( - remove_none_from_dict( - { - "locale": locale, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"pages/{jsonable_encoder(page_id)}/dom", + method="GET", + params={"locale": locale, "limit": limit, "offset": offset}, + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Dom, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(Dom, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -806,19 +856,30 @@ async def update_static_content( locale: str, nodes: typing.Sequence[DomWriteNodesItem], request_options: typing.Optional[RequestOptions] = None, - ) -> Dom: + ) -> UpdateStaticContentResponse: """ Update static content on a static page. This endpoint supports sending 1000 nodes per request.

Required scope | `pages:write` - Parameters: - - page_id: str. Unique identifier for a Page + Parameters + ---------- + page_id : str + Unique identifier for a Page + + locale : str + The locale identifier. - - locale: str. The locale identifier. + nodes : typing.Sequence[DomWriteNodesItem] - - nodes: typing.Sequence[DomWriteNodesItem]. + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Returns + ------- + UpdateStaticContentResponse + Request was successful + + Examples + -------- from webflow import DomWriteNodesItem from webflow.client import AsyncWebflow @@ -830,60 +891,43 @@ async def update_static_content( locale="locale", nodes=[ DomWriteNodesItem( - node_id="guide-title-id", - text="

Hello world

", - ) + node_id="a245c12d-995b-55ee-5ec7-aa36a6cad623", + text="

The Hitchhiker's Guide to the Galaxy

", + ), + DomWriteNodesItem( + node_id="a245c12d-995b-55ee-5ec7-aa36a6cad627", + text="

Don't Panic!

Always know where your towel is.

", + ), + DomWriteNodesItem( + node_id="a245c12d-995b-55ee-5ec7-aa36a6cad629", + text="Marvin, the Paranoid Android", + ), ], ) """ _response = await self._client_wrapper.httpx_client.request( - "POST", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"pages/{jsonable_encoder(page_id)}/dom"), - params=jsonable_encoder( - remove_none_from_dict( - { - "locale": locale, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - json=jsonable_encoder({"nodes": nodes}) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder({"nodes": nodes}), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"pages/{jsonable_encoder(page_id)}/dom", + method="POST", + params={"locale": locale}, + json={"nodes": nodes}, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Dom, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(UpdateStaticContentResponse, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/src/webflow/resources/pages/resources/scripts/client.py b/src/webflow/resources/pages/resources/scripts/client.py index db07c75..1895650 100644 --- a/src/webflow/resources/pages/resources/scripts/client.py +++ b/src/webflow/resources/pages/resources/scripts/client.py @@ -1,26 +1,21 @@ # This file was auto-generated by Fern from our API Definition. import typing -import urllib.parse from json.decoder import JSONDecodeError from .....core.api_error import ApiError from .....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from .....core.jsonable_encoder import jsonable_encoder -from .....core.remove_none_from_dict import remove_none_from_dict +from .....core.pydantic_utilities import pydantic_v1 from .....core.request_options import RequestOptions from .....errors.bad_request_error import BadRequestError from .....errors.internal_server_error import InternalServerError from .....errors.not_found_error import NotFoundError from .....errors.too_many_requests_error import TooManyRequestsError from .....errors.unauthorized_error import UnauthorizedError +from .....types.script_apply import ScriptApply from .....types.script_apply_list import ScriptApplyList -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -33,13 +28,23 @@ def get_custom_code( self, page_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> ScriptApplyList: """ - Get all registered scripts that have been applied to a specific Page.

In order to use the Custom Code APIs for Sites and Pages, Custom Code Scripts must first be registered to a Site via the `registered_scripts` endpoints, and then applied to a Site or Page using the appropriate `custom_code` endpoints.

Access to this endpoint requires a bearer token from a Data Client App. Required scope | `custom_code:read` + Get all registered scripts that have been applied to a specific Page.

In order to use the Custom Code APIs for Sites and Pages, Custom Code Scripts must first be registered to a Site via the `registered_scripts` endpoints, and then applied to a Site or Page using the appropriate `custom_code` endpoints.
Access to this endpoint requires a bearer token from a Data Client App.
Required scope | `custom_code:read` + + Parameters + ---------- + page_id : str + Unique identifier for a Page + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - Parameters: - - page_id: str. Unique identifier for a Page + Returns + ------- + ScriptApplyList + Request was successful - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -50,57 +55,63 @@ def get_custom_code( ) """ _response = self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"pages/{jsonable_encoder(page_id)}/custom_code" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"pages/{jsonable_encoder(page_id)}/custom_code", method="GET", request_options=request_options ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(ScriptApplyList, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(ScriptApplyList, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) def upsert_custom_code( - self, page_id: str, *, request: ScriptApplyList, request_options: typing.Optional[RequestOptions] = None + self, + page_id: str, + *, + scripts: typing.Optional[typing.Sequence[ScriptApply]] = OMIT, + last_updated: typing.Optional[str] = OMIT, + created_on: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, ) -> ScriptApplyList: """ - Add a registered script to a Page.

In order to use the Custom Code APIs for Sites and Pages, Custom Code Scripts must first be registered to a Site via the `registered_scripts` endpoints, and then applied to a Site or Page using the appropriate `custom_code` endpoints.

Access to this endpoint requires a bearer token from a Data Client App. Required scope | `custom_code:write` + Add a registered script to a Page.

In order to use the Custom Code APIs for Sites and Pages, Custom Code Scripts must first be registered to a Site via the `registered_scripts` endpoints, and then applied to a Site or Page using the appropriate `custom_code` endpoints.
Access to this endpoint requires a bearer token from a Data Client App.
Required scope | `custom_code:write` + + Parameters + ---------- + page_id : str + Unique identifier for a Page + + scripts : typing.Optional[typing.Sequence[ScriptApply]] + A list of scripts applied to a Site or a Page - Parameters: - - page_id: str. Unique identifier for a Page + last_updated : typing.Optional[str] + Date when the Site's scripts were last updated - - request: ScriptApplyList. + created_on : typing.Optional[str] + Date when the Site's scripts were created - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- - from webflow import ScriptApply, ScriptApplyList, ScriptApplyLocation + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ScriptApplyList + Request was successful + + Examples + -------- + from webflow import ScriptApply, ScriptApplyLocation from webflow.client import Webflow client = Webflow( @@ -108,67 +119,41 @@ def upsert_custom_code( ) client.pages.scripts.upsert_custom_code( page_id="page_id", - request=ScriptApplyList( - scripts=[ - ScriptApply( - id="cms_slider", - location=ScriptApplyLocation.HEADER, - version="1.0.0", - attributes={"my-attribute": "some-value"}, - ), - ScriptApply( - id="alert", - location=ScriptApplyLocation.HEADER, - version="0.0.1", - ), - ScriptApply( - id="id", - location=ScriptApplyLocation.HEADER, - version="version", - ), - ], - ), + scripts=[ + ScriptApply( + id="cms_slider", + location=ScriptApplyLocation.HEADER, + version="1.0.0", + attributes={"my-attribute": "some-value"}, + ), + ScriptApply( + id="alert", + location=ScriptApplyLocation.HEADER, + version="0.0.1", + ), + ], ) """ _response = self._client_wrapper.httpx_client.request( - "PUT", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"pages/{jsonable_encoder(page_id)}/custom_code" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"pages/{jsonable_encoder(page_id)}/custom_code", + method="PUT", + json={"scripts": scripts, "lastUpdated": last_updated, "createdOn": created_on}, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(ScriptApplyList, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(ScriptApplyList, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -176,13 +161,22 @@ def upsert_custom_code( def delete_custom_code(self, page_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: """ - Delete the custom code block that an app has created for a page

In order to use the Custom Code APIs for Sites and Pages, Custom Code Scripts must first be registered to a Site via the `registered_scripts` endpoints, and then applied to a Site or Page using the appropriate `custom_code` endpoints.

Access to this endpoint requires a bearer token from a Data Client App. Required scope | `custom_code:write` + Delete the custom code block that an app has created for a page

In order to use the Custom Code APIs for Sites and Pages, Custom Code Scripts must first be registered to a Site via the `registered_scripts` endpoints, and then applied to a Site or Page using the appropriate `custom_code` endpoints.
Access to this endpoint requires a bearer token from a Data Client App.
Required scope | `custom_code:write` + + Parameters + ---------- + page_id : str + Unique identifier for a Page + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - Parameters: - - page_id: str. Unique identifier for a Page + Returns + ------- + None - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -193,38 +187,21 @@ def delete_custom_code(self, page_id: str, *, request_options: typing.Optional[R ) """ _response = self._client_wrapper.httpx_client.request( - "DELETE", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"pages/{jsonable_encoder(page_id)}/custom_code" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"pages/{jsonable_encoder(page_id)}/custom_code", method="DELETE", request_options=request_options ) - if 200 <= _response.status_code < 300: - return - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -239,13 +216,23 @@ async def get_custom_code( self, page_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> ScriptApplyList: """ - Get all registered scripts that have been applied to a specific Page.

In order to use the Custom Code APIs for Sites and Pages, Custom Code Scripts must first be registered to a Site via the `registered_scripts` endpoints, and then applied to a Site or Page using the appropriate `custom_code` endpoints.

Access to this endpoint requires a bearer token from a Data Client App. Required scope | `custom_code:read` + Get all registered scripts that have been applied to a specific Page.

In order to use the Custom Code APIs for Sites and Pages, Custom Code Scripts must first be registered to a Site via the `registered_scripts` endpoints, and then applied to a Site or Page using the appropriate `custom_code` endpoints.
Access to this endpoint requires a bearer token from a Data Client App.
Required scope | `custom_code:read` - Parameters: - - page_id: str. Unique identifier for a Page + Parameters + ---------- + page_id : str + Unique identifier for a Page - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ScriptApplyList + Request was successful + + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -256,57 +243,63 @@ async def get_custom_code( ) """ _response = await self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"pages/{jsonable_encoder(page_id)}/custom_code" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"pages/{jsonable_encoder(page_id)}/custom_code", method="GET", request_options=request_options ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(ScriptApplyList, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(ScriptApplyList, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) async def upsert_custom_code( - self, page_id: str, *, request: ScriptApplyList, request_options: typing.Optional[RequestOptions] = None + self, + page_id: str, + *, + scripts: typing.Optional[typing.Sequence[ScriptApply]] = OMIT, + last_updated: typing.Optional[str] = OMIT, + created_on: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, ) -> ScriptApplyList: """ - Add a registered script to a Page.

In order to use the Custom Code APIs for Sites and Pages, Custom Code Scripts must first be registered to a Site via the `registered_scripts` endpoints, and then applied to a Site or Page using the appropriate `custom_code` endpoints.

Access to this endpoint requires a bearer token from a Data Client App. Required scope | `custom_code:write` + Add a registered script to a Page.

In order to use the Custom Code APIs for Sites and Pages, Custom Code Scripts must first be registered to a Site via the `registered_scripts` endpoints, and then applied to a Site or Page using the appropriate `custom_code` endpoints.
Access to this endpoint requires a bearer token from a Data Client App.
Required scope | `custom_code:write` + + Parameters + ---------- + page_id : str + Unique identifier for a Page + + scripts : typing.Optional[typing.Sequence[ScriptApply]] + A list of scripts applied to a Site or a Page - Parameters: - - page_id: str. Unique identifier for a Page + last_updated : typing.Optional[str] + Date when the Site's scripts were last updated - - request: ScriptApplyList. + created_on : typing.Optional[str] + Date when the Site's scripts were created - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- - from webflow import ScriptApply, ScriptApplyList, ScriptApplyLocation + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ScriptApplyList + Request was successful + + Examples + -------- + from webflow import ScriptApply, ScriptApplyLocation from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -314,67 +307,41 @@ async def upsert_custom_code( ) await client.pages.scripts.upsert_custom_code( page_id="page_id", - request=ScriptApplyList( - scripts=[ - ScriptApply( - id="cms_slider", - location=ScriptApplyLocation.HEADER, - version="1.0.0", - attributes={"my-attribute": "some-value"}, - ), - ScriptApply( - id="alert", - location=ScriptApplyLocation.HEADER, - version="0.0.1", - ), - ScriptApply( - id="id", - location=ScriptApplyLocation.HEADER, - version="version", - ), - ], - ), + scripts=[ + ScriptApply( + id="cms_slider", + location=ScriptApplyLocation.HEADER, + version="1.0.0", + attributes={"my-attribute": "some-value"}, + ), + ScriptApply( + id="alert", + location=ScriptApplyLocation.HEADER, + version="0.0.1", + ), + ], ) """ _response = await self._client_wrapper.httpx_client.request( - "PUT", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"pages/{jsonable_encoder(page_id)}/custom_code" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"pages/{jsonable_encoder(page_id)}/custom_code", + method="PUT", + json={"scripts": scripts, "lastUpdated": last_updated, "createdOn": created_on}, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(ScriptApplyList, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(ScriptApplyList, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -384,13 +351,22 @@ async def delete_custom_code( self, page_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> None: """ - Delete the custom code block that an app has created for a page

In order to use the Custom Code APIs for Sites and Pages, Custom Code Scripts must first be registered to a Site via the `registered_scripts` endpoints, and then applied to a Site or Page using the appropriate `custom_code` endpoints.

Access to this endpoint requires a bearer token from a Data Client App. Required scope | `custom_code:write` + Delete the custom code block that an app has created for a page

In order to use the Custom Code APIs for Sites and Pages, Custom Code Scripts must first be registered to a Site via the `registered_scripts` endpoints, and then applied to a Site or Page using the appropriate `custom_code` endpoints.
Access to this endpoint requires a bearer token from a Data Client App.
Required scope | `custom_code:write` + + Parameters + ---------- + page_id : str + Unique identifier for a Page + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - Parameters: - - page_id: str. Unique identifier for a Page + Returns + ------- + None - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -401,38 +377,21 @@ async def delete_custom_code( ) """ _response = await self._client_wrapper.httpx_client.request( - "DELETE", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"pages/{jsonable_encoder(page_id)}/custom_code" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"pages/{jsonable_encoder(page_id)}/custom_code", method="DELETE", request_options=request_options ) - if 200 <= _response.status_code < 300: - return - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/src/webflow/resources/pages/types/__init__.py b/src/webflow/resources/pages/types/__init__.py index fdefa12..0903928 100644 --- a/src/webflow/resources/pages/types/__init__.py +++ b/src/webflow/resources/pages/types/__init__.py @@ -1,5 +1,6 @@ # This file was auto-generated by Fern from our API Definition. from .dom_write_nodes_item import DomWriteNodesItem +from .update_static_content_response import UpdateStaticContentResponse -__all__ = ["DomWriteNodesItem"] +__all__ = ["DomWriteNodesItem", "UpdateStaticContentResponse"] diff --git a/src/webflow/resources/pages/types/dom_write_nodes_item.py b/src/webflow/resources/pages/types/dom_write_nodes_item.py index 36f7d9b..b37b43b 100644 --- a/src/webflow/resources/pages/types/dom_write_nodes_item.py +++ b/src/webflow/resources/pages/types/dom_write_nodes_item.py @@ -4,27 +4,36 @@ import typing from ....core.datetime_utils import serialize_datetime +from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore +class DomWriteNodesItem(pydantic_v1.BaseModel): + node_id: str = pydantic_v1.Field(alias="nodeId") + """ + Node UUID + """ -class DomWriteNodesItem(pydantic.BaseModel): - node_id: str = pydantic.Field(alias="nodeId", description="Node UUID") - text: str = pydantic.Field(description="HTML content of the node") + text: str = pydantic_v1.Field() + """ + HTML content of the node, including the HTML tag. The HTML tags must be the same as what's returned from the Get Content endpoint. + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/resources/pages/types/update_static_content_response.py b/src/webflow/resources/pages/types/update_static_content_response.py new file mode 100644 index 0000000..f960341 --- /dev/null +++ b/src/webflow/resources/pages/types/update_static_content_response.py @@ -0,0 +1,32 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from ....core.datetime_utils import serialize_datetime +from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 + + +class UpdateStaticContentResponse(pydantic_v1.BaseModel): + errors: typing.List[str] = pydantic_v1.Field() + """ + A list of error messages, if any. + """ + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) + + class Config: + frozen = True + smart_union = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/resources/products/__init__.py b/src/webflow/resources/products/__init__.py index d1569c5..9fced2c 100644 --- a/src/webflow/resources/products/__init__.py +++ b/src/webflow/resources/products/__init__.py @@ -1,31 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -from .types import ( - ProductSkuCreateProduct, - ProductSkuCreateProductFieldData, - ProductSkuCreateProductFieldDataEcProductType, - ProductSkuCreateProductFieldDataTaxCategory, - ProductSkuCreateSku, - ProductSkuCreateSkuFieldData, - ProductSkuCreateSkuFieldDataCompareAtPrice, - ProductSkuCreateSkuFieldDataEcSkuBillingMethod, - ProductSkuCreateSkuFieldDataEcSkuSubscriptionPlan, - ProductSkuCreateSkuFieldDataEcSkuSubscriptionPlanInterval, - ProductSkuCreateSkuFieldDataPrice, - ProductsCreateSkuResponse, -) +from .types import ProductsCreateSkuResponse -__all__ = [ - "ProductSkuCreateProduct", - "ProductSkuCreateProductFieldData", - "ProductSkuCreateProductFieldDataEcProductType", - "ProductSkuCreateProductFieldDataTaxCategory", - "ProductSkuCreateSku", - "ProductSkuCreateSkuFieldData", - "ProductSkuCreateSkuFieldDataCompareAtPrice", - "ProductSkuCreateSkuFieldDataEcSkuBillingMethod", - "ProductSkuCreateSkuFieldDataEcSkuSubscriptionPlan", - "ProductSkuCreateSkuFieldDataEcSkuSubscriptionPlanInterval", - "ProductSkuCreateSkuFieldDataPrice", - "ProductsCreateSkuResponse", -] +__all__ = ["ProductsCreateSkuResponse"] diff --git a/src/webflow/resources/products/client.py b/src/webflow/resources/products/client.py index 4d7180a..fb1896e 100644 --- a/src/webflow/resources/products/client.py +++ b/src/webflow/resources/products/client.py @@ -1,13 +1,12 @@ # This file was auto-generated by Fern from our API Definition. import typing -import urllib.parse from json.decoder import JSONDecodeError from ...core.api_error import ApiError from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ...core.jsonable_encoder import jsonable_encoder -from ...core.remove_none_from_dict import remove_none_from_dict +from ...core.pydantic_utilities import pydantic_v1 from ...core.request_options import RequestOptions from ...errors.bad_request_error import BadRequestError from ...errors.conflict_error import ConflictError @@ -21,15 +20,8 @@ from ...types.product_and_sk_us_list import ProductAndSkUsList from ...types.publish_status import PublishStatus from ...types.sku import Sku -from .types.product_sku_create_product import ProductSkuCreateProduct -from .types.product_sku_create_sku import ProductSkuCreateSku from .types.products_create_sku_response import ProductsCreateSkuResponse -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -51,15 +43,27 @@ def list( Required scope | `ecommerce:read` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site + + offset : typing.Optional[float] + Offset used for pagination if the results have more than limit records - - offset: typing.Optional[float]. Offset used for pagination if the results have more than limit records + limit : typing.Optional[float] + Maximum number of records to be returned (max limit: 100) - - limit: typing.Optional[float]. Maximum number of records to be returned (max limit: 100) + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Returns + ------- + ProductAndSkUsList + Request was successful + + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -70,52 +74,28 @@ def list( ) """ _response = self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/products" - ), - params=jsonable_encoder( - remove_none_from_dict( - { - "offset": offset, - "limit": limit, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/products", + method="GET", + params={"offset": offset, "limit": limit}, + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(ProductAndSkUsList, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 409: - raise ConflictError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(ProductAndSkUsList, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 409: + raise ConflictError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -126,8 +106,8 @@ def create( site_id: str, *, publish_status: typing.Optional[PublishStatus] = OMIT, - product: typing.Optional[ProductSkuCreateProduct] = OMIT, - sku: typing.Optional[ProductSkuCreateSku] = OMIT, + product: typing.Optional[Product] = OMIT, + sku: typing.Optional[Sku] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> ProductAndSkUs: """ @@ -141,17 +121,27 @@ def create( Required scope | `ecommerce:write` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site + + publish_status : typing.Optional[PublishStatus] - - publish_status: typing.Optional[PublishStatus]. + product : typing.Optional[Product] - - product: typing.Optional[ProductSkuCreateProduct]. The Product Object + sku : typing.Optional[Sku] - - sku: typing.Optional[ProductSkuCreateSku]. The SKU object + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Returns + ------- + ProductAndSkUs + Request was successful + + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -161,56 +151,30 @@ def create( site_id="site_id", ) """ - _request: typing.Dict[str, typing.Any] = {} - if publish_status is not OMIT: - _request["publishStatus"] = publish_status.value if publish_status is not None else None - if product is not OMIT: - _request["product"] = product - if sku is not OMIT: - _request["sku"] = sku _response = self._client_wrapper.httpx_client.request( - "POST", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/products" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/products", + method="POST", + json={"publishStatus": publish_status, "product": product, "sku": sku}, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(ProductAndSkUs, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 409: - raise ConflictError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(ProductAndSkUs, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 409: + raise ConflictError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -224,13 +188,24 @@ def get( Required scope | `ecommerce:read` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site + + product_id : str + Unique identifier for a Product - - product_id: str. Unique identifier for a Product + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Returns + ------- + ProductAndSkUs + Request was successful + + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -242,43 +217,27 @@ def get( ) """ _response = self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"sites/{jsonable_encoder(site_id)}/products/{jsonable_encoder(product_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/products/{jsonable_encoder(product_id)}", + method="GET", + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(ProductAndSkUs, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 409: - raise ConflictError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(ProductAndSkUs, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 409: + raise ConflictError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -290,7 +249,8 @@ def update( product_id: str, *, publish_status: typing.Optional[PublishStatus] = OMIT, - product: Product, + product: typing.Optional[Product] = OMIT, + sku: typing.Optional[Sku] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> Product: """ @@ -298,25 +258,30 @@ def update( Required scope | `ecommerce:write` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site - - product_id: str. Unique identifier for a Product + product_id : str + Unique identifier for a Product - - publish_status: typing.Optional[PublishStatus]. + publish_status : typing.Optional[PublishStatus] - - product: Product. + product : typing.Optional[Product] - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- - import datetime + sku : typing.Optional[Sku] - from webflow import ( - Product, - ProductFieldData, - SkuPropertyList, - SkuPropertyListEnumItem, - ) + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + Product + Request was successful + + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -325,114 +290,32 @@ def update( client.products.update( site_id="site_id", product_id="product_id", - product=Product( - id="580e63fc8c9a982ac9b8b745", - last_published=datetime.datetime.fromisoformat( - "2023-03-17 18:47:35+00:00", - ), - last_updated=datetime.datetime.fromisoformat( - "2023-03-17 18:47:35+00:00", - ), - created_on=datetime.datetime.fromisoformat( - "2023-03-17 18:47:35+00:00", - ), - is_archived=False, - is_draft=False, - field_data=ProductFieldData( - name="T-Shirt", - slug="t-shirt", - description="A plain cotton t-shirt.", - shippable=True, - sku_properties=[ - SkuPropertyList( - id="color", - name="Color", - enum=[ - SkuPropertyListEnumItem( - id="royal-blue", - name="Royal Blue", - slug="royal-blue", - ), - SkuPropertyListEnumItem( - id="crimson-red", - name="Crimson Red", - slug="crimson-red", - ), - SkuPropertyListEnumItem( - id="forrest-green", - name="name", - slug="slug", - ), - SkuPropertyListEnumItem( - id="id", - name="name", - slug="slug", - ), - ], - ), - SkuPropertyList( - id="Color", - name="Color", - enum=[ - SkuPropertyListEnumItem( - id="id", - name="name", - slug="slug", - ) - ], - ), - ], - ), - ), ) """ - _request: typing.Dict[str, typing.Any] = {"product": product} - if publish_status is not OMIT: - _request["publishStatus"] = publish_status.value if publish_status is not None else None _response = self._client_wrapper.httpx_client.request( - "PATCH", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"sites/{jsonable_encoder(site_id)}/products/{jsonable_encoder(product_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/products/{jsonable_encoder(product_id)}", + method="PATCH", + json={"publishStatus": publish_status, "product": product, "sku": sku}, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Product, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 409: - raise ConflictError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(Product, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 409: + raise ConflictError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -443,8 +326,8 @@ def create_sku( site_id: str, product_id: str, *, - publish_status: typing.Optional[PublishStatus] = OMIT, skus: typing.Sequence[Sku], + publish_status: typing.Optional[PublishStatus] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> ProductsCreateSkuResponse: """ @@ -454,20 +337,30 @@ def create_sku( Required scope | `ecommerce:write` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site - - product_id: str. Unique identifier for a Product + product_id : str + Unique identifier for a Product - - publish_status: typing.Optional[PublishStatus]. + skus : typing.Sequence[Sku] + An array of the SKU data your are adding - - skus: typing.Sequence[Sku]. An array of the SKU data your are adding + publish_status : typing.Optional[PublishStatus] - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- - import datetime + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - from webflow import Sku, SkuFieldData, SkuFieldDataPrice + Returns + ------- + ProductsCreateSkuResponse + Request was successful + + Examples + -------- + from webflow import Sku from webflow.client import Webflow client = Webflow( @@ -476,78 +369,33 @@ def create_sku( client.products.create_sku( site_id="site_id", product_id="product_id", - skus=[ - Sku( - id="580e63fc8c9a982ac9b8b745", - last_published=datetime.datetime.fromisoformat( - "2023-03-17 18:47:35+00:00", - ), - last_updated=datetime.datetime.fromisoformat( - "2023-03-17 18:47:35+00:00", - ), - created_on=datetime.datetime.fromisoformat( - "2023-03-17 18:47:35+00:00", - ), - field_data=SkuFieldData( - name="Blue T-shirt", - slug="t-shirt-blue", - price=SkuFieldDataPrice( - value=100.0, - unit="USD", - ), - quantity=10.0, - ), - ) - ], + skus=[Sku()], ) """ - _request: typing.Dict[str, typing.Any] = {"skus": skus} - if publish_status is not OMIT: - _request["publishStatus"] = publish_status.value if publish_status is not None else None _response = self._client_wrapper.httpx_client.request( - "POST", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"sites/{jsonable_encoder(site_id)}/products/{jsonable_encoder(product_id)}/skus", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/products/{jsonable_encoder(product_id)}/skus", + method="POST", + json={"publishStatus": publish_status, "skus": skus}, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(ProductsCreateSkuResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 409: - raise ConflictError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(ProductsCreateSkuResponse, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 409: + raise ConflictError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -559,8 +407,8 @@ def update_sku( product_id: str, sku_id: str, *, - publish_status: typing.Optional[PublishStatus] = OMIT, sku: Sku, + publish_status: typing.Optional[PublishStatus] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> Sku: """ @@ -568,22 +416,32 @@ def update_sku( Required scope | `ecommerce:write` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site + + product_id : str + Unique identifier for a Product - - product_id: str. Unique identifier for a Product + sku_id : str + Unique identifier for a SKU - - sku_id: str. Unique identifier for a SKU + sku : Sku - - publish_status: typing.Optional[PublishStatus]. + publish_status : typing.Optional[PublishStatus] - - sku: Sku. + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- - import datetime + Returns + ------- + Sku + Request was successful - from webflow import Sku, SkuFieldData, SkuFieldDataPrice + Examples + -------- + from webflow import Sku from webflow.client import Webflow client = Webflow( @@ -593,76 +451,33 @@ def update_sku( site_id="site_id", product_id="product_id", sku_id="sku_id", - sku=Sku( - id="580e63fc8c9a982ac9b8b745", - last_published=datetime.datetime.fromisoformat( - "2023-03-17 18:47:35+00:00", - ), - last_updated=datetime.datetime.fromisoformat( - "2023-03-17 18:47:35+00:00", - ), - created_on=datetime.datetime.fromisoformat( - "2023-03-17 18:47:35+00:00", - ), - field_data=SkuFieldData( - name="Blue T-shirt", - slug="t-shirt-blue", - price=SkuFieldDataPrice( - value=100.0, - unit="USD", - ), - quantity=10.0, - ), - ), + sku=Sku(), ) """ - _request: typing.Dict[str, typing.Any] = {"sku": sku} - if publish_status is not OMIT: - _request["publishStatus"] = publish_status.value if publish_status is not None else None _response = self._client_wrapper.httpx_client.request( - "PATCH", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"sites/{jsonable_encoder(site_id)}/products/{jsonable_encoder(product_id)}/skus/{jsonable_encoder(sku_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/products/{jsonable_encoder(product_id)}/skus/{jsonable_encoder(sku_id)}", + method="PATCH", + json={"publishStatus": publish_status, "sku": sku}, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Sku, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 409: - raise ConflictError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(Sku, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 409: + raise ConflictError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -686,15 +501,27 @@ async def list( Required scope | `ecommerce:read` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site - - offset: typing.Optional[float]. Offset used for pagination if the results have more than limit records + offset : typing.Optional[float] + Offset used for pagination if the results have more than limit records - - limit: typing.Optional[float]. Maximum number of records to be returned (max limit: 100) + limit : typing.Optional[float] + Maximum number of records to be returned (max limit: 100) - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ProductAndSkUsList + Request was successful + + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -705,52 +532,28 @@ async def list( ) """ _response = await self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/products" - ), - params=jsonable_encoder( - remove_none_from_dict( - { - "offset": offset, - "limit": limit, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/products", + method="GET", + params={"offset": offset, "limit": limit}, + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(ProductAndSkUsList, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 409: - raise ConflictError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(ProductAndSkUsList, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 409: + raise ConflictError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -761,8 +564,8 @@ async def create( site_id: str, *, publish_status: typing.Optional[PublishStatus] = OMIT, - product: typing.Optional[ProductSkuCreateProduct] = OMIT, - sku: typing.Optional[ProductSkuCreateSku] = OMIT, + product: typing.Optional[Product] = OMIT, + sku: typing.Optional[Sku] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> ProductAndSkUs: """ @@ -776,17 +579,27 @@ async def create( Required scope | `ecommerce:write` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site + + publish_status : typing.Optional[PublishStatus] + + product : typing.Optional[Product] - - publish_status: typing.Optional[PublishStatus]. + sku : typing.Optional[Sku] - - product: typing.Optional[ProductSkuCreateProduct]. The Product Object + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - sku: typing.Optional[ProductSkuCreateSku]. The SKU object + Returns + ------- + ProductAndSkUs + Request was successful - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -796,56 +609,30 @@ async def create( site_id="site_id", ) """ - _request: typing.Dict[str, typing.Any] = {} - if publish_status is not OMIT: - _request["publishStatus"] = publish_status.value if publish_status is not None else None - if product is not OMIT: - _request["product"] = product - if sku is not OMIT: - _request["sku"] = sku _response = await self._client_wrapper.httpx_client.request( - "POST", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/products" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/products", + method="POST", + json={"publishStatus": publish_status, "product": product, "sku": sku}, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(ProductAndSkUs, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 409: - raise ConflictError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(ProductAndSkUs, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 409: + raise ConflictError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -859,13 +646,24 @@ async def get( Required scope | `ecommerce:read` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site - - product_id: str. Unique identifier for a Product + product_id : str + Unique identifier for a Product - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ProductAndSkUs + Request was successful + + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -877,43 +675,27 @@ async def get( ) """ _response = await self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"sites/{jsonable_encoder(site_id)}/products/{jsonable_encoder(product_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/products/{jsonable_encoder(product_id)}", + method="GET", + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(ProductAndSkUs, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 409: - raise ConflictError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(ProductAndSkUs, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 409: + raise ConflictError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -925,7 +707,8 @@ async def update( product_id: str, *, publish_status: typing.Optional[PublishStatus] = OMIT, - product: Product, + product: typing.Optional[Product] = OMIT, + sku: typing.Optional[Sku] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> Product: """ @@ -933,25 +716,30 @@ async def update( Required scope | `ecommerce:write` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site - - product_id: str. Unique identifier for a Product + product_id : str + Unique identifier for a Product - - publish_status: typing.Optional[PublishStatus]. + publish_status : typing.Optional[PublishStatus] - - product: Product. + product : typing.Optional[Product] - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- - import datetime + sku : typing.Optional[Sku] - from webflow import ( - Product, - ProductFieldData, - SkuPropertyList, - SkuPropertyListEnumItem, - ) + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + Product + Request was successful + + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -960,114 +748,32 @@ async def update( await client.products.update( site_id="site_id", product_id="product_id", - product=Product( - id="580e63fc8c9a982ac9b8b745", - last_published=datetime.datetime.fromisoformat( - "2023-03-17 18:47:35+00:00", - ), - last_updated=datetime.datetime.fromisoformat( - "2023-03-17 18:47:35+00:00", - ), - created_on=datetime.datetime.fromisoformat( - "2023-03-17 18:47:35+00:00", - ), - is_archived=False, - is_draft=False, - field_data=ProductFieldData( - name="T-Shirt", - slug="t-shirt", - description="A plain cotton t-shirt.", - shippable=True, - sku_properties=[ - SkuPropertyList( - id="color", - name="Color", - enum=[ - SkuPropertyListEnumItem( - id="royal-blue", - name="Royal Blue", - slug="royal-blue", - ), - SkuPropertyListEnumItem( - id="crimson-red", - name="Crimson Red", - slug="crimson-red", - ), - SkuPropertyListEnumItem( - id="forrest-green", - name="name", - slug="slug", - ), - SkuPropertyListEnumItem( - id="id", - name="name", - slug="slug", - ), - ], - ), - SkuPropertyList( - id="Color", - name="Color", - enum=[ - SkuPropertyListEnumItem( - id="id", - name="name", - slug="slug", - ) - ], - ), - ], - ), - ), ) """ - _request: typing.Dict[str, typing.Any] = {"product": product} - if publish_status is not OMIT: - _request["publishStatus"] = publish_status.value if publish_status is not None else None _response = await self._client_wrapper.httpx_client.request( - "PATCH", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"sites/{jsonable_encoder(site_id)}/products/{jsonable_encoder(product_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/products/{jsonable_encoder(product_id)}", + method="PATCH", + json={"publishStatus": publish_status, "product": product, "sku": sku}, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Product, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 409: - raise ConflictError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(Product, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 409: + raise ConflictError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -1078,8 +784,8 @@ async def create_sku( site_id: str, product_id: str, *, - publish_status: typing.Optional[PublishStatus] = OMIT, skus: typing.Sequence[Sku], + publish_status: typing.Optional[PublishStatus] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> ProductsCreateSkuResponse: """ @@ -1089,20 +795,30 @@ async def create_sku( Required scope | `ecommerce:write` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site + + product_id : str + Unique identifier for a Product - - product_id: str. Unique identifier for a Product + skus : typing.Sequence[Sku] + An array of the SKU data your are adding - - publish_status: typing.Optional[PublishStatus]. + publish_status : typing.Optional[PublishStatus] - - skus: typing.Sequence[Sku]. An array of the SKU data your are adding + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- - import datetime + Returns + ------- + ProductsCreateSkuResponse + Request was successful - from webflow import Sku, SkuFieldData, SkuFieldDataPrice + Examples + -------- + from webflow import Sku from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -1111,78 +827,33 @@ async def create_sku( await client.products.create_sku( site_id="site_id", product_id="product_id", - skus=[ - Sku( - id="580e63fc8c9a982ac9b8b745", - last_published=datetime.datetime.fromisoformat( - "2023-03-17 18:47:35+00:00", - ), - last_updated=datetime.datetime.fromisoformat( - "2023-03-17 18:47:35+00:00", - ), - created_on=datetime.datetime.fromisoformat( - "2023-03-17 18:47:35+00:00", - ), - field_data=SkuFieldData( - name="Blue T-shirt", - slug="t-shirt-blue", - price=SkuFieldDataPrice( - value=100.0, - unit="USD", - ), - quantity=10.0, - ), - ) - ], + skus=[Sku()], ) """ - _request: typing.Dict[str, typing.Any] = {"skus": skus} - if publish_status is not OMIT: - _request["publishStatus"] = publish_status.value if publish_status is not None else None _response = await self._client_wrapper.httpx_client.request( - "POST", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"sites/{jsonable_encoder(site_id)}/products/{jsonable_encoder(product_id)}/skus", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/products/{jsonable_encoder(product_id)}/skus", + method="POST", + json={"publishStatus": publish_status, "skus": skus}, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(ProductsCreateSkuResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 409: - raise ConflictError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(ProductsCreateSkuResponse, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 409: + raise ConflictError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -1194,8 +865,8 @@ async def update_sku( product_id: str, sku_id: str, *, - publish_status: typing.Optional[PublishStatus] = OMIT, sku: Sku, + publish_status: typing.Optional[PublishStatus] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> Sku: """ @@ -1203,22 +874,32 @@ async def update_sku( Required scope | `ecommerce:write` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site + + product_id : str + Unique identifier for a Product - - product_id: str. Unique identifier for a Product + sku_id : str + Unique identifier for a SKU - - sku_id: str. Unique identifier for a SKU + sku : Sku - - publish_status: typing.Optional[PublishStatus]. + publish_status : typing.Optional[PublishStatus] - - sku: Sku. + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- - import datetime + Returns + ------- + Sku + Request was successful - from webflow import Sku, SkuFieldData, SkuFieldDataPrice + Examples + -------- + from webflow import Sku from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -1228,76 +909,33 @@ async def update_sku( site_id="site_id", product_id="product_id", sku_id="sku_id", - sku=Sku( - id="580e63fc8c9a982ac9b8b745", - last_published=datetime.datetime.fromisoformat( - "2023-03-17 18:47:35+00:00", - ), - last_updated=datetime.datetime.fromisoformat( - "2023-03-17 18:47:35+00:00", - ), - created_on=datetime.datetime.fromisoformat( - "2023-03-17 18:47:35+00:00", - ), - field_data=SkuFieldData( - name="Blue T-shirt", - slug="t-shirt-blue", - price=SkuFieldDataPrice( - value=100.0, - unit="USD", - ), - quantity=10.0, - ), - ), + sku=Sku(), ) """ - _request: typing.Dict[str, typing.Any] = {"sku": sku} - if publish_status is not OMIT: - _request["publishStatus"] = publish_status.value if publish_status is not None else None _response = await self._client_wrapper.httpx_client.request( - "PATCH", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"sites/{jsonable_encoder(site_id)}/products/{jsonable_encoder(product_id)}/skus/{jsonable_encoder(sku_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/products/{jsonable_encoder(product_id)}/skus/{jsonable_encoder(sku_id)}", + method="PATCH", + json={"publishStatus": publish_status, "sku": sku}, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Sku, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 409: - raise ConflictError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(Sku, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 409: + raise ConflictError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/src/webflow/resources/products/types/__init__.py b/src/webflow/resources/products/types/__init__.py index 55ac9d6..b078afe 100644 --- a/src/webflow/resources/products/types/__init__.py +++ b/src/webflow/resources/products/types/__init__.py @@ -1,33 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -from .product_sku_create_product import ProductSkuCreateProduct -from .product_sku_create_product_field_data import ProductSkuCreateProductFieldData -from .product_sku_create_product_field_data_ec_product_type import ProductSkuCreateProductFieldDataEcProductType -from .product_sku_create_product_field_data_tax_category import ProductSkuCreateProductFieldDataTaxCategory -from .product_sku_create_sku import ProductSkuCreateSku -from .product_sku_create_sku_field_data import ProductSkuCreateSkuFieldData -from .product_sku_create_sku_field_data_compare_at_price import ProductSkuCreateSkuFieldDataCompareAtPrice -from .product_sku_create_sku_field_data_ec_sku_billing_method import ProductSkuCreateSkuFieldDataEcSkuBillingMethod -from .product_sku_create_sku_field_data_ec_sku_subscription_plan import ( - ProductSkuCreateSkuFieldDataEcSkuSubscriptionPlan, -) -from .product_sku_create_sku_field_data_ec_sku_subscription_plan_interval import ( - ProductSkuCreateSkuFieldDataEcSkuSubscriptionPlanInterval, -) -from .product_sku_create_sku_field_data_price import ProductSkuCreateSkuFieldDataPrice from .products_create_sku_response import ProductsCreateSkuResponse -__all__ = [ - "ProductSkuCreateProduct", - "ProductSkuCreateProductFieldData", - "ProductSkuCreateProductFieldDataEcProductType", - "ProductSkuCreateProductFieldDataTaxCategory", - "ProductSkuCreateSku", - "ProductSkuCreateSkuFieldData", - "ProductSkuCreateSkuFieldDataCompareAtPrice", - "ProductSkuCreateSkuFieldDataEcSkuBillingMethod", - "ProductSkuCreateSkuFieldDataEcSkuSubscriptionPlan", - "ProductSkuCreateSkuFieldDataEcSkuSubscriptionPlanInterval", - "ProductSkuCreateSkuFieldDataPrice", - "ProductsCreateSkuResponse", -] +__all__ = ["ProductsCreateSkuResponse"] diff --git a/src/webflow/resources/products/types/product_sku_create_product.py b/src/webflow/resources/products/types/product_sku_create_product.py deleted file mode 100644 index 6e410b8..0000000 --- a/src/webflow/resources/products/types/product_sku_create_product.py +++ /dev/null @@ -1,50 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import datetime as dt -import typing - -from ....core.datetime_utils import serialize_datetime -from .product_sku_create_product_field_data import ProductSkuCreateProductFieldData - -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - - -class ProductSkuCreateProduct(pydantic.BaseModel): - """ - The Product Object - """ - - id: typing.Optional[str] = pydantic.Field(default=None, description="Unique identifier for the Product") - last_published: typing.Optional[dt.datetime] = pydantic.Field( - alias="lastPublished", default=None, description="The date the Product was last published" - ) - last_updated: typing.Optional[dt.datetime] = pydantic.Field( - alias="lastUpdated", default=None, description="The date the Product was last updated" - ) - created_on: typing.Optional[dt.datetime] = pydantic.Field( - alias="createdOn", default=None, description="The date the Product was created" - ) - is_archived: typing.Optional[bool] = pydantic.Field( - alias="isArchived", default=None, description="Boolean determining if the Product is set to archived" - ) - is_draft: typing.Optional[bool] = pydantic.Field( - alias="isDraft", default=None, description="Boolean determining if the Product is set to draft" - ) - field_data: typing.Optional[ProductSkuCreateProductFieldData] = pydantic.Field(alias="fieldData", default=None) - - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) - - class Config: - frozen = True - smart_union = True - allow_population_by_field_name = True - json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/resources/products/types/product_sku_create_product_field_data.py b/src/webflow/resources/products/types/product_sku_create_product_field_data.py deleted file mode 100644 index 2748896..0000000 --- a/src/webflow/resources/products/types/product_sku_create_product_field_data.py +++ /dev/null @@ -1,52 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import datetime as dt -import typing - -from ....core.datetime_utils import serialize_datetime -from ....types.sku_property_list import SkuPropertyList -from .product_sku_create_product_field_data_ec_product_type import ProductSkuCreateProductFieldDataEcProductType -from .product_sku_create_product_field_data_tax_category import ProductSkuCreateProductFieldDataTaxCategory - -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - - -class ProductSkuCreateProductFieldData(pydantic.BaseModel): - name: str = pydantic.Field(description="Name of the Product") - slug: str = pydantic.Field(description="URL structure of the Product in your site.") - description: typing.Optional[str] = pydantic.Field(default=None, description="A description of your product") - shippable: typing.Optional[bool] = pydantic.Field( - default=None, description="Boolean determining if the Product is shippable" - ) - sku_properties: typing.Optional[typing.List[SkuPropertyList]] = pydantic.Field( - alias="sku-properties", default=None, description="Variant types to include in SKUs" - ) - categories: typing.Optional[typing.List[typing.Any]] = pydantic.Field( - default=None, description="The categories your product belongs to." - ) - tax_category: typing.Optional[ProductSkuCreateProductFieldDataTaxCategory] = pydantic.Field( - alias="tax-category", default=None, description="Product tax class" - ) - ec_product_type: typing.Optional[ProductSkuCreateProductFieldDataEcProductType] = pydantic.Field( - alias="ec-product-type", - default=None, - description='Product types. Enums reflect the following values in order: Physical, Digital, Service, Advanced"', - ) - additional_properties: typing.Optional[typing.Any] = pydantic.Field(alias="additionalProperties", default=None) - - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) - - class Config: - frozen = True - smart_union = True - allow_population_by_field_name = True - json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/resources/products/types/product_sku_create_product_field_data_ec_product_type.py b/src/webflow/resources/products/types/product_sku_create_product_field_data_ec_product_type.py deleted file mode 100644 index 05f521c..0000000 --- a/src/webflow/resources/products/types/product_sku_create_product_field_data_ec_product_type.py +++ /dev/null @@ -1,33 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import enum -import typing - -T_Result = typing.TypeVar("T_Result") - - -class ProductSkuCreateProductFieldDataEcProductType(str, enum.Enum): - """ - Product types. Enums reflect the following values in order: Physical, Digital, Service, Advanced" - """ - - FF_42_FEE_0113744_F_693_A_764_E_3431_A_9_CC_2 = "ff42fee0113744f693a764e3431a9cc2" - F_22027_DB_68002190_AEF_89_A_4_A_2_B_7_AC_8_A_1 = "f22027db68002190aef89a4a2b7ac8a1" - C_599_E_43_B_1_A_1_C_34_D_5_A_323_AEDF_75_D_3_ADF_6 = "c599e43b1a1c34d5a323aedf75d3adf6" - B_6_CCC_1830_DB_4_B_1_BABEB_06_A_9_AC_5_F_6_DD_76 = "b6ccc1830db4b1babeb06a9ac5f6dd76" - - def visit( - self, - ff_42_fee_0113744_f_693_a_764_e_3431_a_9_cc_2: typing.Callable[[], T_Result], - f_22027_db_68002190_aef_89_a_4_a_2_b_7_ac_8_a_1: typing.Callable[[], T_Result], - c_599_e_43_b_1_a_1_c_34_d_5_a_323_aedf_75_d_3_adf_6: typing.Callable[[], T_Result], - b_6_ccc_1830_db_4_b_1_babeb_06_a_9_ac_5_f_6_dd_76: typing.Callable[[], T_Result], - ) -> T_Result: - if self is ProductSkuCreateProductFieldDataEcProductType.FF_42_FEE_0113744_F_693_A_764_E_3431_A_9_CC_2: - return ff_42_fee_0113744_f_693_a_764_e_3431_a_9_cc_2() - if self is ProductSkuCreateProductFieldDataEcProductType.F_22027_DB_68002190_AEF_89_A_4_A_2_B_7_AC_8_A_1: - return f_22027_db_68002190_aef_89_a_4_a_2_b_7_ac_8_a_1() - if self is ProductSkuCreateProductFieldDataEcProductType.C_599_E_43_B_1_A_1_C_34_D_5_A_323_AEDF_75_D_3_ADF_6: - return c_599_e_43_b_1_a_1_c_34_d_5_a_323_aedf_75_d_3_adf_6() - if self is ProductSkuCreateProductFieldDataEcProductType.B_6_CCC_1830_DB_4_B_1_BABEB_06_A_9_AC_5_F_6_DD_76: - return b_6_ccc_1830_db_4_b_1_babeb_06_a_9_ac_5_f_6_dd_76() diff --git a/src/webflow/resources/products/types/product_sku_create_product_field_data_tax_category.py b/src/webflow/resources/products/types/product_sku_create_product_field_data_tax_category.py deleted file mode 100644 index a2eb210..0000000 --- a/src/webflow/resources/products/types/product_sku_create_product_field_data_tax_category.py +++ /dev/null @@ -1,133 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import enum -import typing - -T_Result = typing.TypeVar("T_Result") - - -class ProductSkuCreateProductFieldDataTaxCategory(str, enum.Enum): - """ - Product tax class - """ - - STANDARD_TAXABLE = "standard-taxable" - STANDARD_EXEMPT = "standard-exempt" - BOOKS_RELIGIOUS = "books-religious" - BOOKS_TEXTBOOK = "books-textbook" - CLOTHING = "clothing" - CLOTHING_SWIMWEAR = "clothing-swimwear" - DIGITAL_GOODS = "digital-goods" - DIGITAL_SERVICE = "digital-service" - DRUGS_NON_PRESCRIPTION = "drugs-non-prescription" - DRUGS_PRESCRIPTION = "drugs-prescription" - FOOD_BOTTLED_WATER = "food-bottled-water" - FOOD_CANDY = "food-candy" - FOOD_GROCERIES = "food-groceries" - FOOD_PREPARED = "food-prepared" - FOOD_SODA = "food-soda" - FOOD_SUPPLEMENTS = "food-supplements" - MAGAZINE_INDIVIDUAL = "magazine-individual" - MAGAZINE_SUBSCRIPTION = "magazine-subscription" - SERVICE_ADMISSION = "service-admission" - SERVICE_ADVERTISING = "service-advertising" - SERVICE_DRY_CLEANING = "service-dry-cleaning" - SERVICE_HAIRDRESSING = "service-hairdressing" - SERVICE_INSTALLATION = "service-installation" - SERVICE_MISCELLANEOUS = "service-miscellaneous" - SERVICE_PARKING = "service-parking" - SERVICE_PRINTING = "service-printing" - SERVICE_PROFESSIONAL = "service-professional" - SERVICE_REPAIR = "service-repair" - SERVICE_TRAINING = "service-training" - - def visit( - self, - standard_taxable: typing.Callable[[], T_Result], - standard_exempt: typing.Callable[[], T_Result], - books_religious: typing.Callable[[], T_Result], - books_textbook: typing.Callable[[], T_Result], - clothing: typing.Callable[[], T_Result], - clothing_swimwear: typing.Callable[[], T_Result], - digital_goods: typing.Callable[[], T_Result], - digital_service: typing.Callable[[], T_Result], - drugs_non_prescription: typing.Callable[[], T_Result], - drugs_prescription: typing.Callable[[], T_Result], - food_bottled_water: typing.Callable[[], T_Result], - food_candy: typing.Callable[[], T_Result], - food_groceries: typing.Callable[[], T_Result], - food_prepared: typing.Callable[[], T_Result], - food_soda: typing.Callable[[], T_Result], - food_supplements: typing.Callable[[], T_Result], - magazine_individual: typing.Callable[[], T_Result], - magazine_subscription: typing.Callable[[], T_Result], - service_admission: typing.Callable[[], T_Result], - service_advertising: typing.Callable[[], T_Result], - service_dry_cleaning: typing.Callable[[], T_Result], - service_hairdressing: typing.Callable[[], T_Result], - service_installation: typing.Callable[[], T_Result], - service_miscellaneous: typing.Callable[[], T_Result], - service_parking: typing.Callable[[], T_Result], - service_printing: typing.Callable[[], T_Result], - service_professional: typing.Callable[[], T_Result], - service_repair: typing.Callable[[], T_Result], - service_training: typing.Callable[[], T_Result], - ) -> T_Result: - if self is ProductSkuCreateProductFieldDataTaxCategory.STANDARD_TAXABLE: - return standard_taxable() - if self is ProductSkuCreateProductFieldDataTaxCategory.STANDARD_EXEMPT: - return standard_exempt() - if self is ProductSkuCreateProductFieldDataTaxCategory.BOOKS_RELIGIOUS: - return books_religious() - if self is ProductSkuCreateProductFieldDataTaxCategory.BOOKS_TEXTBOOK: - return books_textbook() - if self is ProductSkuCreateProductFieldDataTaxCategory.CLOTHING: - return clothing() - if self is ProductSkuCreateProductFieldDataTaxCategory.CLOTHING_SWIMWEAR: - return clothing_swimwear() - if self is ProductSkuCreateProductFieldDataTaxCategory.DIGITAL_GOODS: - return digital_goods() - if self is ProductSkuCreateProductFieldDataTaxCategory.DIGITAL_SERVICE: - return digital_service() - if self is ProductSkuCreateProductFieldDataTaxCategory.DRUGS_NON_PRESCRIPTION: - return drugs_non_prescription() - if self is ProductSkuCreateProductFieldDataTaxCategory.DRUGS_PRESCRIPTION: - return drugs_prescription() - if self is ProductSkuCreateProductFieldDataTaxCategory.FOOD_BOTTLED_WATER: - return food_bottled_water() - if self is ProductSkuCreateProductFieldDataTaxCategory.FOOD_CANDY: - return food_candy() - if self is ProductSkuCreateProductFieldDataTaxCategory.FOOD_GROCERIES: - return food_groceries() - if self is ProductSkuCreateProductFieldDataTaxCategory.FOOD_PREPARED: - return food_prepared() - if self is ProductSkuCreateProductFieldDataTaxCategory.FOOD_SODA: - return food_soda() - if self is ProductSkuCreateProductFieldDataTaxCategory.FOOD_SUPPLEMENTS: - return food_supplements() - if self is ProductSkuCreateProductFieldDataTaxCategory.MAGAZINE_INDIVIDUAL: - return magazine_individual() - if self is ProductSkuCreateProductFieldDataTaxCategory.MAGAZINE_SUBSCRIPTION: - return magazine_subscription() - if self is ProductSkuCreateProductFieldDataTaxCategory.SERVICE_ADMISSION: - return service_admission() - if self is ProductSkuCreateProductFieldDataTaxCategory.SERVICE_ADVERTISING: - return service_advertising() - if self is ProductSkuCreateProductFieldDataTaxCategory.SERVICE_DRY_CLEANING: - return service_dry_cleaning() - if self is ProductSkuCreateProductFieldDataTaxCategory.SERVICE_HAIRDRESSING: - return service_hairdressing() - if self is ProductSkuCreateProductFieldDataTaxCategory.SERVICE_INSTALLATION: - return service_installation() - if self is ProductSkuCreateProductFieldDataTaxCategory.SERVICE_MISCELLANEOUS: - return service_miscellaneous() - if self is ProductSkuCreateProductFieldDataTaxCategory.SERVICE_PARKING: - return service_parking() - if self is ProductSkuCreateProductFieldDataTaxCategory.SERVICE_PRINTING: - return service_printing() - if self is ProductSkuCreateProductFieldDataTaxCategory.SERVICE_PROFESSIONAL: - return service_professional() - if self is ProductSkuCreateProductFieldDataTaxCategory.SERVICE_REPAIR: - return service_repair() - if self is ProductSkuCreateProductFieldDataTaxCategory.SERVICE_TRAINING: - return service_training() diff --git a/src/webflow/resources/products/types/product_sku_create_sku.py b/src/webflow/resources/products/types/product_sku_create_sku.py deleted file mode 100644 index 2877e3c..0000000 --- a/src/webflow/resources/products/types/product_sku_create_sku.py +++ /dev/null @@ -1,46 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import datetime as dt -import typing - -from ....core.datetime_utils import serialize_datetime -from .product_sku_create_sku_field_data import ProductSkuCreateSkuFieldData - -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - - -class ProductSkuCreateSku(pydantic.BaseModel): - """ - The SKU object - """ - - id: typing.Optional[str] = pydantic.Field(default=None, description="Unique identifier for the Product") - last_published: typing.Optional[dt.datetime] = pydantic.Field( - alias="lastPublished", default=None, description="The date the Product was last published" - ) - last_updated: typing.Optional[dt.datetime] = pydantic.Field( - alias="lastUpdated", default=None, description="The date the Product was last updated" - ) - created_on: typing.Optional[dt.datetime] = pydantic.Field( - alias="createdOn", default=None, description="The date the Product was created" - ) - field_data: typing.Optional[ProductSkuCreateSkuFieldData] = pydantic.Field( - alias="fieldData", default=None, description="Standard and Custom fields for a SKU" - ) - - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) - - class Config: - frozen = True - smart_union = True - allow_population_by_field_name = True - json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/resources/products/types/product_sku_create_sku_field_data.py b/src/webflow/resources/products/types/product_sku_create_sku_field_data.py deleted file mode 100644 index 621cba9..0000000 --- a/src/webflow/resources/products/types/product_sku_create_sku_field_data.py +++ /dev/null @@ -1,62 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import datetime as dt -import typing - -from ....core.datetime_utils import serialize_datetime -from ....types.sku_value_list import SkuValueList -from .product_sku_create_sku_field_data_compare_at_price import ProductSkuCreateSkuFieldDataCompareAtPrice -from .product_sku_create_sku_field_data_ec_sku_billing_method import ProductSkuCreateSkuFieldDataEcSkuBillingMethod -from .product_sku_create_sku_field_data_ec_sku_subscription_plan import ( - ProductSkuCreateSkuFieldDataEcSkuSubscriptionPlan, -) -from .product_sku_create_sku_field_data_price import ProductSkuCreateSkuFieldDataPrice - -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - - -class ProductSkuCreateSkuFieldData(pydantic.BaseModel): - """ - Standard and Custom fields for a SKU - """ - - sku_values: typing.Optional[SkuValueList] = pydantic.Field(alias="sku-values", default=None) - name: str = pydantic.Field(description="Name of the Product") - slug: str = pydantic.Field(description="URL structure of the Product in your site.") - price: ProductSkuCreateSkuFieldDataPrice = pydantic.Field(description="price of SKU") - compare_at_price: typing.Optional[ProductSkuCreateSkuFieldDataCompareAtPrice] = pydantic.Field( - alias="compare-at-price", default=None, description="comparison price of SKU" - ) - ec_sku_billing_method: typing.Optional[ProductSkuCreateSkuFieldDataEcSkuBillingMethod] = pydantic.Field( - alias="ec-sku-billing-method", default=None, description="The billing method for your SKU" - ) - ec_sku_subscription_plan: typing.Optional[ProductSkuCreateSkuFieldDataEcSkuSubscriptionPlan] = pydantic.Field( - alias="ec-sku-subscription-plan", - default=None, - description="If your billing method is a Subscription Plan, outline the type and frequency of the subscription.", - ) - track_inventory: typing.Optional[bool] = pydantic.Field( - alias="track-inventory", - default=None, - description="A boolean indicating whether inventory for this product should be tracked.", - ) - quantity: typing.Optional[float] = pydantic.Field( - default=None, description="Quantity of SKU that will be tracked as items are ordered." - ) - - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) - - class Config: - frozen = True - smart_union = True - allow_population_by_field_name = True - json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/resources/products/types/product_sku_create_sku_field_data_compare_at_price.py b/src/webflow/resources/products/types/product_sku_create_sku_field_data_compare_at_price.py deleted file mode 100644 index ea8c8b8..0000000 --- a/src/webflow/resources/products/types/product_sku_create_sku_field_data_compare_at_price.py +++ /dev/null @@ -1,33 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import datetime as dt -import typing - -from ....core.datetime_utils import serialize_datetime - -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - - -class ProductSkuCreateSkuFieldDataCompareAtPrice(pydantic.BaseModel): - """ - comparison price of SKU - """ - - value: typing.Optional[float] = pydantic.Field(default=None, description="Price of SKU") - unit: typing.Optional[str] = pydantic.Field(default=None, description="Currency of Item") - - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) - - class Config: - frozen = True - smart_union = True - json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/resources/products/types/product_sku_create_sku_field_data_ec_sku_billing_method.py b/src/webflow/resources/products/types/product_sku_create_sku_field_data_ec_sku_billing_method.py deleted file mode 100644 index 9b4e545..0000000 --- a/src/webflow/resources/products/types/product_sku_create_sku_field_data_ec_sku_billing_method.py +++ /dev/null @@ -1,21 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import enum -import typing - -T_Result = typing.TypeVar("T_Result") - - -class ProductSkuCreateSkuFieldDataEcSkuBillingMethod(str, enum.Enum): - """ - The billing method for your SKU - """ - - ONE_TIME = "one-time" - SUBSCRIPTION = "subscription" - - def visit(self, one_time: typing.Callable[[], T_Result], subscription: typing.Callable[[], T_Result]) -> T_Result: - if self is ProductSkuCreateSkuFieldDataEcSkuBillingMethod.ONE_TIME: - return one_time() - if self is ProductSkuCreateSkuFieldDataEcSkuBillingMethod.SUBSCRIPTION: - return subscription() diff --git a/src/webflow/resources/products/types/product_sku_create_sku_field_data_ec_sku_subscription_plan.py b/src/webflow/resources/products/types/product_sku_create_sku_field_data_ec_sku_subscription_plan.py deleted file mode 100644 index 16df5eb..0000000 --- a/src/webflow/resources/products/types/product_sku_create_sku_field_data_ec_sku_subscription_plan.py +++ /dev/null @@ -1,39 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import datetime as dt -import typing - -from ....core.datetime_utils import serialize_datetime -from .product_sku_create_sku_field_data_ec_sku_subscription_plan_interval import ( - ProductSkuCreateSkuFieldDataEcSkuSubscriptionPlanInterval, -) - -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - - -class ProductSkuCreateSkuFieldDataEcSkuSubscriptionPlan(pydantic.BaseModel): - """ - If your billing method is a Subscription Plan, outline the type and frequency of the subscription. - """ - - interval: typing.Optional[ProductSkuCreateSkuFieldDataEcSkuSubscriptionPlanInterval] = pydantic.Field( - default=None, description="Interval of subscription renewal" - ) - frequency: typing.Optional[float] = pydantic.Field(default=None, description="Frequncy of billing within interval") - trial: typing.Optional[float] = pydantic.Field(default=None, description="Number of days of a trial") - - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) - - class Config: - frozen = True - smart_union = True - json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/resources/products/types/product_sku_create_sku_field_data_ec_sku_subscription_plan_interval.py b/src/webflow/resources/products/types/product_sku_create_sku_field_data_ec_sku_subscription_plan_interval.py deleted file mode 100644 index 07093ba..0000000 --- a/src/webflow/resources/products/types/product_sku_create_sku_field_data_ec_sku_subscription_plan_interval.py +++ /dev/null @@ -1,33 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import enum -import typing - -T_Result = typing.TypeVar("T_Result") - - -class ProductSkuCreateSkuFieldDataEcSkuSubscriptionPlanInterval(str, enum.Enum): - """ - Interval of subscription renewal - """ - - DAY = "day" - WEEK = "week" - MONTH = "month" - YEAR = "year" - - def visit( - self, - day: typing.Callable[[], T_Result], - week: typing.Callable[[], T_Result], - month: typing.Callable[[], T_Result], - year: typing.Callable[[], T_Result], - ) -> T_Result: - if self is ProductSkuCreateSkuFieldDataEcSkuSubscriptionPlanInterval.DAY: - return day() - if self is ProductSkuCreateSkuFieldDataEcSkuSubscriptionPlanInterval.WEEK: - return week() - if self is ProductSkuCreateSkuFieldDataEcSkuSubscriptionPlanInterval.MONTH: - return month() - if self is ProductSkuCreateSkuFieldDataEcSkuSubscriptionPlanInterval.YEAR: - return year() diff --git a/src/webflow/resources/products/types/product_sku_create_sku_field_data_price.py b/src/webflow/resources/products/types/product_sku_create_sku_field_data_price.py deleted file mode 100644 index 9a430e4..0000000 --- a/src/webflow/resources/products/types/product_sku_create_sku_field_data_price.py +++ /dev/null @@ -1,34 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import datetime as dt -import typing - -from ....core.datetime_utils import serialize_datetime - -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - - -class ProductSkuCreateSkuFieldDataPrice(pydantic.BaseModel): - """ - price of SKU - """ - - required: typing.Optional[typing.Any] = None - value: typing.Optional[float] = pydantic.Field(default=None, description="Price of SKU") - unit: typing.Optional[str] = pydantic.Field(default=None, description="Currency of Item") - - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) - - class Config: - frozen = True - smart_union = True - json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/resources/products/types/products_create_sku_response.py b/src/webflow/resources/products/types/products_create_sku_response.py index c176596..ddff764 100644 --- a/src/webflow/resources/products/types/products_create_sku_response.py +++ b/src/webflow/resources/products/types/products_create_sku_response.py @@ -4,15 +4,11 @@ import typing from ....core.datetime_utils import serialize_datetime +from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ....types.sku import Sku -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class ProductsCreateSkuResponse(pydantic.BaseModel): +class ProductsCreateSkuResponse(pydantic_v1.BaseModel): skus: typing.Optional[typing.List[Sku]] = None def json(self, **kwargs: typing.Any) -> str: @@ -20,10 +16,15 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/resources/scripts/client.py b/src/webflow/resources/scripts/client.py index dae0212..473d57e 100644 --- a/src/webflow/resources/scripts/client.py +++ b/src/webflow/resources/scripts/client.py @@ -1,27 +1,22 @@ # This file was auto-generated by Fern from our API Definition. import typing -import urllib.parse from json.decoder import JSONDecodeError from ...core.api_error import ApiError from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ...core.jsonable_encoder import jsonable_encoder -from ...core.remove_none_from_dict import remove_none_from_dict +from ...core.pydantic_utilities import pydantic_v1 from ...core.request_options import RequestOptions from ...errors.bad_request_error import BadRequestError from ...errors.internal_server_error import InternalServerError from ...errors.not_found_error import NotFoundError from ...errors.too_many_requests_error import TooManyRequestsError from ...errors.unauthorized_error import UnauthorizedError -from ...types.custom_code_response import CustomCodeResponse +from ...types.custom_code_hosted_response import CustomCodeHostedResponse +from ...types.custom_code_inline_response import CustomCodeInlineResponse from ...types.registered_script_list import RegisteredScriptList -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -32,13 +27,23 @@ def __init__(self, *, client_wrapper: SyncClientWrapper): def list(self, site_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> RegisteredScriptList: """ - List of scripts registered to a Site.

In order to use the Custom Code APIs for Sites and Pages, Custom Code Scripts must first be registered to a Site via the `registered_scripts` endpoints, and then applied to a Site or Page using the appropriate `custom_code` endpoints. Additionally, Scripts can be remotely hosted, or registered as inline snippets. Access to this endpoint requires a bearer token from a Data Client App.

Required scope | `custom_code:read` + List of scripts registered to a Site.

In order to use the Custom Code APIs for Sites and Pages, Custom Code Scripts must first be registered to a Site via the `registered_scripts` endpoints, and then applied to a Site or Page using the appropriate `custom_code` endpoints. Additionally, Scripts can be remotely hosted, or registered as inline snippets.
Access to this endpoint requires a bearer token from a Data Client App.
Required scope | `custom_code:read` + + Parameters + ---------- + site_id : str + Unique identifier for a Site - Parameters: - - site_id: str. Unique identifier for a Site + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Returns + ------- + RegisteredScriptList + Request was successful + + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -49,38 +54,21 @@ def list(self, site_id: str, *, request_options: typing.Optional[RequestOptions] ) """ _response = self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/registered_scripts" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/registered_scripts", method="GET", request_options=request_options ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(RegisteredScriptList, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(RegisteredScriptList, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -92,29 +80,44 @@ def register_hosted( *, hosted_location: str, integrity_hash: str, - can_copy: typing.Optional[bool] = OMIT, version: str, display_name: str, + can_copy: typing.Optional[bool] = OMIT, request_options: typing.Optional[RequestOptions] = None, - ) -> CustomCodeResponse: + ) -> CustomCodeHostedResponse: """ - Add a script to a Site's Custom Code registry.

In order to use the Custom Code APIs for Sites and Pages, Custom Code Scripts must first be registered to a Site via the `registered_scripts` endpoints, and then applied to a Site or Page using the appropriate `custom_code` endpoints. Additionally, Scripts can be remotely hosted, or registered as inline snippets. Access to this endpoint requires a bearer token from a Data Client App.

Required scope | `custom_code:write` + Add a script to a Site's Custom Code registry.

In order to use the Custom Code APIs for Sites and Pages, Custom Code Scripts must first be registered to a Site via the `registered_scripts` endpoints, and then applied to a Site or Page using the appropriate `custom_code` endpoints. Additionally, Scripts can be remotely hosted, or registered as inline snippets.
Access to this endpoint requires a bearer token from a Data Client App.


Required scope | `custom_code:write` + + Parameters + ---------- + site_id : str + Unique identifier for a Site + + hosted_location : str + URI for an externally hosted script location - Parameters: - - site_id: str. Unique identifier for a Site + integrity_hash : str + Sub-Resource Integrity Hash - - hosted_location: str. URI for an externally hosted script location + version : str + A Semantic Version (SemVer) string, denoting the version of the script - - integrity_hash: str. Sub-Resource Integrity Hash + display_name : str + User-facing name for the script. Must be between 1 and 50 alphanumeric characters - - can_copy: typing.Optional[bool]. Define whether the script can be copied on site duplication and transfer + can_copy : typing.Optional[bool] + Define whether the script can be copied on site duplication and transfer - - version: str. A Semantic Version (SemVer) string, denoting the version of the script + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - display_name: str. User-facing name for the script + Returns + ------- + CustomCodeHostedResponse + Request was successful - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -128,54 +131,32 @@ def register_hosted( display_name="displayName", ) """ - _request: typing.Dict[str, typing.Any] = { - "hostedLocation": hosted_location, - "integrityHash": integrity_hash, - "version": version, - "displayName": display_name, - } - if can_copy is not OMIT: - _request["canCopy"] = can_copy _response = self._client_wrapper.httpx_client.request( - "POST", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"sites/{jsonable_encoder(site_id)}/registered_scripts/hosted", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + f"sites/{jsonable_encoder(site_id)}/registered_scripts/hosted", + method="POST", + json={ + "hostedLocation": hosted_location, + "integrityHash": integrity_hash, + "canCopy": can_copy, + "version": version, + "displayName": display_name, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(CustomCodeResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(CustomCodeHostedResponse, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -186,30 +167,45 @@ def register_inline( site_id: str, *, source_code: str, - integrity_hash: typing.Optional[str] = OMIT, - can_copy: typing.Optional[bool] = OMIT, version: str, display_name: str, + integrity_hash: typing.Optional[str] = OMIT, + can_copy: typing.Optional[bool] = OMIT, request_options: typing.Optional[RequestOptions] = None, - ) -> CustomCodeResponse: + ) -> CustomCodeInlineResponse: """ - Add a script to a Site's Custom Code registry. Inline scripts can be between 1 and 2000 characters.

In order to use the Custom Code APIs for Sites and Pages, Custom Code Scripts must first be registered to a Site via the `registered_scripts` endpoints, and then applied to a Site or Page using the appropriate `custom_code` endpoints.

Access to this endpoint requires a bearer token from a Data Client App. Required scope | `custom_code:write` + Add a script to a Site's Custom Code registry. Inline scripts can be between 1 and 2000 characters.

In order to use the Custom Code APIs for Sites and Pages, Custom Code Scripts must first be registered to a Site via the `registered_scripts` endpoints, and then applied to a Site or Page using the appropriate `custom_code` endpoints.

Access to this endpoint requires a bearer token from a Data Client App.
Required scope | `custom_code:write` + + Parameters + ---------- + site_id : str + Unique identifier for a Site + + source_code : str + The code to be added to the site (to be hosted by Webflow). - Parameters: - - site_id: str. Unique identifier for a Site + version : str + A Semantic Version (SemVer) string, denoting the version of the script - - source_code: str. The code to be added to the site (to be hosted by Webflow). + display_name : str + User-facing name for the script. Must be between 1 and 50 alphanumeric characters - - integrity_hash: typing.Optional[str]. Sub-Resource Integrity Hash. Only required for externally hosted scripts (passed via hostedLocation) + integrity_hash : typing.Optional[str] + Sub-Resource Integrity Hash. Only required for externally hosted scripts (passed via hostedLocation) - - can_copy: typing.Optional[bool]. Define whether the script can be copied on site duplication and transfer + can_copy : typing.Optional[bool] + Define whether the script can be copied on site duplication and transfer - - version: str. A Semantic Version (SemVer) string, denoting the version of the script + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - display_name: str. User-facing name for the script + Returns + ------- + CustomCodeInlineResponse + Created - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -222,55 +218,32 @@ def register_inline( display_name="Alert", ) """ - _request: typing.Dict[str, typing.Any] = { - "sourceCode": source_code, - "version": version, - "displayName": display_name, - } - if integrity_hash is not OMIT: - _request["integrityHash"] = integrity_hash - if can_copy is not OMIT: - _request["canCopy"] = can_copy _response = self._client_wrapper.httpx_client.request( - "POST", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"sites/{jsonable_encoder(site_id)}/registered_scripts/inline", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + f"sites/{jsonable_encoder(site_id)}/registered_scripts/inline", + method="POST", + json={ + "sourceCode": source_code, + "integrityHash": integrity_hash, + "canCopy": can_copy, + "version": version, + "displayName": display_name, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(CustomCodeResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(CustomCodeInlineResponse, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -285,13 +258,23 @@ async def list( self, site_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> RegisteredScriptList: """ - List of scripts registered to a Site.

In order to use the Custom Code APIs for Sites and Pages, Custom Code Scripts must first be registered to a Site via the `registered_scripts` endpoints, and then applied to a Site or Page using the appropriate `custom_code` endpoints. Additionally, Scripts can be remotely hosted, or registered as inline snippets. Access to this endpoint requires a bearer token from a Data Client App.

Required scope | `custom_code:read` + List of scripts registered to a Site.

In order to use the Custom Code APIs for Sites and Pages, Custom Code Scripts must first be registered to a Site via the `registered_scripts` endpoints, and then applied to a Site or Page using the appropriate `custom_code` endpoints. Additionally, Scripts can be remotely hosted, or registered as inline snippets.
Access to this endpoint requires a bearer token from a Data Client App.
Required scope | `custom_code:read` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + RegisteredScriptList + Request was successful + + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -302,38 +285,21 @@ async def list( ) """ _response = await self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/registered_scripts" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/registered_scripts", method="GET", request_options=request_options ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(RegisteredScriptList, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(RegisteredScriptList, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -345,29 +311,44 @@ async def register_hosted( *, hosted_location: str, integrity_hash: str, - can_copy: typing.Optional[bool] = OMIT, version: str, display_name: str, + can_copy: typing.Optional[bool] = OMIT, request_options: typing.Optional[RequestOptions] = None, - ) -> CustomCodeResponse: + ) -> CustomCodeHostedResponse: """ - Add a script to a Site's Custom Code registry.

In order to use the Custom Code APIs for Sites and Pages, Custom Code Scripts must first be registered to a Site via the `registered_scripts` endpoints, and then applied to a Site or Page using the appropriate `custom_code` endpoints. Additionally, Scripts can be remotely hosted, or registered as inline snippets. Access to this endpoint requires a bearer token from a Data Client App.

Required scope | `custom_code:write` + Add a script to a Site's Custom Code registry.

In order to use the Custom Code APIs for Sites and Pages, Custom Code Scripts must first be registered to a Site via the `registered_scripts` endpoints, and then applied to a Site or Page using the appropriate `custom_code` endpoints. Additionally, Scripts can be remotely hosted, or registered as inline snippets.
Access to this endpoint requires a bearer token from a Data Client App.


Required scope | `custom_code:write` + + Parameters + ---------- + site_id : str + Unique identifier for a Site + + hosted_location : str + URI for an externally hosted script location - Parameters: - - site_id: str. Unique identifier for a Site + integrity_hash : str + Sub-Resource Integrity Hash - - hosted_location: str. URI for an externally hosted script location + version : str + A Semantic Version (SemVer) string, denoting the version of the script - - integrity_hash: str. Sub-Resource Integrity Hash + display_name : str + User-facing name for the script. Must be between 1 and 50 alphanumeric characters - - can_copy: typing.Optional[bool]. Define whether the script can be copied on site duplication and transfer + can_copy : typing.Optional[bool] + Define whether the script can be copied on site duplication and transfer - - version: str. A Semantic Version (SemVer) string, denoting the version of the script + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - display_name: str. User-facing name for the script + Returns + ------- + CustomCodeHostedResponse + Request was successful - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -381,54 +362,32 @@ async def register_hosted( display_name="displayName", ) """ - _request: typing.Dict[str, typing.Any] = { - "hostedLocation": hosted_location, - "integrityHash": integrity_hash, - "version": version, - "displayName": display_name, - } - if can_copy is not OMIT: - _request["canCopy"] = can_copy _response = await self._client_wrapper.httpx_client.request( - "POST", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"sites/{jsonable_encoder(site_id)}/registered_scripts/hosted", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + f"sites/{jsonable_encoder(site_id)}/registered_scripts/hosted", + method="POST", + json={ + "hostedLocation": hosted_location, + "integrityHash": integrity_hash, + "canCopy": can_copy, + "version": version, + "displayName": display_name, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(CustomCodeResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(CustomCodeHostedResponse, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -439,30 +398,45 @@ async def register_inline( site_id: str, *, source_code: str, - integrity_hash: typing.Optional[str] = OMIT, - can_copy: typing.Optional[bool] = OMIT, version: str, display_name: str, + integrity_hash: typing.Optional[str] = OMIT, + can_copy: typing.Optional[bool] = OMIT, request_options: typing.Optional[RequestOptions] = None, - ) -> CustomCodeResponse: + ) -> CustomCodeInlineResponse: """ - Add a script to a Site's Custom Code registry. Inline scripts can be between 1 and 2000 characters.

In order to use the Custom Code APIs for Sites and Pages, Custom Code Scripts must first be registered to a Site via the `registered_scripts` endpoints, and then applied to a Site or Page using the appropriate `custom_code` endpoints.

Access to this endpoint requires a bearer token from a Data Client App. Required scope | `custom_code:write` + Add a script to a Site's Custom Code registry. Inline scripts can be between 1 and 2000 characters.

In order to use the Custom Code APIs for Sites and Pages, Custom Code Scripts must first be registered to a Site via the `registered_scripts` endpoints, and then applied to a Site or Page using the appropriate `custom_code` endpoints.

Access to this endpoint requires a bearer token from a Data Client App.
Required scope | `custom_code:write` + + Parameters + ---------- + site_id : str + Unique identifier for a Site + + source_code : str + The code to be added to the site (to be hosted by Webflow). - Parameters: - - site_id: str. Unique identifier for a Site + version : str + A Semantic Version (SemVer) string, denoting the version of the script - - source_code: str. The code to be added to the site (to be hosted by Webflow). + display_name : str + User-facing name for the script. Must be between 1 and 50 alphanumeric characters - - integrity_hash: typing.Optional[str]. Sub-Resource Integrity Hash. Only required for externally hosted scripts (passed via hostedLocation) + integrity_hash : typing.Optional[str] + Sub-Resource Integrity Hash. Only required for externally hosted scripts (passed via hostedLocation) - - can_copy: typing.Optional[bool]. Define whether the script can be copied on site duplication and transfer + can_copy : typing.Optional[bool] + Define whether the script can be copied on site duplication and transfer - - version: str. A Semantic Version (SemVer) string, denoting the version of the script + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - display_name: str. User-facing name for the script + Returns + ------- + CustomCodeInlineResponse + Created - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -475,55 +449,32 @@ async def register_inline( display_name="Alert", ) """ - _request: typing.Dict[str, typing.Any] = { - "sourceCode": source_code, - "version": version, - "displayName": display_name, - } - if integrity_hash is not OMIT: - _request["integrityHash"] = integrity_hash - if can_copy is not OMIT: - _request["canCopy"] = can_copy _response = await self._client_wrapper.httpx_client.request( - "POST", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"sites/{jsonable_encoder(site_id)}/registered_scripts/inline", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + f"sites/{jsonable_encoder(site_id)}/registered_scripts/inline", + method="POST", + json={ + "sourceCode": source_code, + "integrityHash": integrity_hash, + "canCopy": can_copy, + "version": version, + "displayName": display_name, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(CustomCodeResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(CustomCodeInlineResponse, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/src/webflow/resources/sites/client.py b/src/webflow/resources/sites/client.py index ee321fe..24b355d 100644 --- a/src/webflow/resources/sites/client.py +++ b/src/webflow/resources/sites/client.py @@ -1,13 +1,12 @@ # This file was auto-generated by Fern from our API Definition. import typing -import urllib.parse from json.decoder import JSONDecodeError from ...core.api_error import ApiError from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ...core.jsonable_encoder import jsonable_encoder -from ...core.remove_none_from_dict import remove_none_from_dict +from ...core.pydantic_utilities import pydantic_v1 from ...core.request_options import RequestOptions from ...errors.bad_request_error import BadRequestError from ...errors.forbidden_error import ForbiddenError @@ -17,14 +16,10 @@ from ...errors.unauthorized_error import UnauthorizedError from ...types.domains import Domains from ...types.site import Site +from ...types.sites import Sites from .resources.activity_logs.client import ActivityLogsClient, AsyncActivityLogsClient from .resources.scripts.client import AsyncScriptsClient, ScriptsClient -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -35,13 +30,22 @@ def __init__(self, *, client_wrapper: SyncClientWrapper): self.activity_logs = ActivityLogsClient(client_wrapper=self._client_wrapper) self.scripts = ScriptsClient(client_wrapper=self._client_wrapper) - def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> Site: + def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> Sites: """ List of all sites the provided access token is able to access.

Required scope | `sites:read` - Parameters: - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + Sites + Request was successful + + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -49,37 +53,20 @@ def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> Si ) client.sites.list() """ - _response = self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "sites"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, - ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Site, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore + _response = self._client_wrapper.httpx_client.request("sites", method="GET", request_options=request_options) try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(Sites, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -89,11 +76,21 @@ def get(self, site_id: str, *, request_options: typing.Optional[RequestOptions] """ Get a site by site id

Required scope | `sites:read` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + Site + Request was successful + + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -104,36 +101,21 @@ def get(self, site_id: str, *, request_options: typing.Optional[RequestOptions] ) """ _response = self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}", method="GET", request_options=request_options ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Site, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(Site, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -143,11 +125,21 @@ def get_custom_domain(self, site_id: str, *, request_options: typing.Optional[Re """ Get a list of all custom domains related to site.

Required scope | `sites:read` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Returns + ------- + Domains + Request was successful + + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -158,38 +150,21 @@ def get_custom_domain(self, site_id: str, *, request_options: typing.Optional[Re ) """ _response = self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/custom_domains" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/custom_domains", method="GET", request_options=request_options ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Domains, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(Domains, _response.json()) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -206,15 +181,26 @@ def publish( """ Publish a site to one more more domains.

Required scope | `sites:write` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site + + custom_domains : typing.Optional[typing.Sequence[str]] + Array of Custom Domain ids to publish - - custom_domains: typing.Optional[typing.Sequence[str]]. Array of Custom Domain ids to publish + publish_to_webflow_subdomain : typing.Optional[bool] + Choice of whether to publish to the default Webflow Subdomain - - publish_to_webflow_subdomain: typing.Optional[bool]. Choice of whether to publish to the default Webflow Subdomain + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Returns + ------- + None + + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -222,53 +208,28 @@ def publish( ) client.sites.publish( site_id="site_id", - publish_to_webflow_subdomain=False, ) """ - _request: typing.Dict[str, typing.Any] = {} - if custom_domains is not OMIT: - _request["customDomains"] = custom_domains - if publish_to_webflow_subdomain is not OMIT: - _request["publishToWebflowSubdomain"] = publish_to_webflow_subdomain _response = self._client_wrapper.httpx_client.request( - "POST", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/publish" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/publish", + method="POST", + json={"customDomains": custom_domains, "publishToWebflowSubdomain": publish_to_webflow_subdomain}, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -281,13 +242,22 @@ def __init__(self, *, client_wrapper: AsyncClientWrapper): self.activity_logs = AsyncActivityLogsClient(client_wrapper=self._client_wrapper) self.scripts = AsyncScriptsClient(client_wrapper=self._client_wrapper) - async def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> Site: + async def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> Sites: """ List of all sites the provided access token is able to access.

Required scope | `sites:read` - Parameters: - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + Sites + Request was successful + + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -296,36 +266,21 @@ async def list(self, *, request_options: typing.Optional[RequestOptions] = None) await client.sites.list() """ _response = await self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "sites"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + "sites", method="GET", request_options=request_options ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Site, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(Sites, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -335,11 +290,21 @@ async def get(self, site_id: str, *, request_options: typing.Optional[RequestOpt """ Get a site by site id

Required scope | `sites:read` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + Site + Request was successful - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -350,36 +315,21 @@ async def get(self, site_id: str, *, request_options: typing.Optional[RequestOpt ) """ _response = await self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}", method="GET", request_options=request_options ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Site, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(Site, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -391,11 +341,21 @@ async def get_custom_domain( """ Get a list of all custom domains related to site.

Required scope | `sites:read` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + Domains + Request was successful + + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -406,38 +366,21 @@ async def get_custom_domain( ) """ _response = await self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/custom_domains" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/custom_domains", method="GET", request_options=request_options ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Domains, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(Domains, _response.json()) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -454,15 +397,26 @@ async def publish( """ Publish a site to one more more domains.

Required scope | `sites:write` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site + + custom_domains : typing.Optional[typing.Sequence[str]] + Array of Custom Domain ids to publish + + publish_to_webflow_subdomain : typing.Optional[bool] + Choice of whether to publish to the default Webflow Subdomain - - custom_domains: typing.Optional[typing.Sequence[str]]. Array of Custom Domain ids to publish + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - publish_to_webflow_subdomain: typing.Optional[bool]. Choice of whether to publish to the default Webflow Subdomain + Returns + ------- + None - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -470,53 +424,28 @@ async def publish( ) await client.sites.publish( site_id="site_id", - publish_to_webflow_subdomain=False, ) """ - _request: typing.Dict[str, typing.Any] = {} - if custom_domains is not OMIT: - _request["customDomains"] = custom_domains - if publish_to_webflow_subdomain is not OMIT: - _request["publishToWebflowSubdomain"] = publish_to_webflow_subdomain _response = await self._client_wrapper.httpx_client.request( - "POST", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/publish" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/publish", + method="POST", + json={"customDomains": custom_domains, "publishToWebflowSubdomain": publish_to_webflow_subdomain}, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/src/webflow/resources/sites/resources/activity_logs/client.py b/src/webflow/resources/sites/resources/activity_logs/client.py index a0edffd..63571d4 100644 --- a/src/webflow/resources/sites/resources/activity_logs/client.py +++ b/src/webflow/resources/sites/resources/activity_logs/client.py @@ -1,13 +1,12 @@ # This file was auto-generated by Fern from our API Definition. import typing -import urllib.parse from json.decoder import JSONDecodeError from .....core.api_error import ApiError from .....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from .....core.jsonable_encoder import jsonable_encoder -from .....core.remove_none_from_dict import remove_none_from_dict +from .....core.pydantic_utilities import pydantic_v1 from .....core.request_options import RequestOptions from .....errors.forbidden_error import ForbiddenError from .....errors.internal_server_error import InternalServerError @@ -15,11 +14,6 @@ from .....errors.too_many_requests_error import TooManyRequestsError from .....types.site_activity_log_response import SiteActivityLogResponse -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - class ActivityLogsClient: def __init__(self, *, client_wrapper: SyncClientWrapper): @@ -36,15 +30,27 @@ def list( """ Retrieve Activity Logs for a specific Site. Requires Site to be on an Enterprise plan.

Required scope | `site_activity:read` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site + + limit : typing.Optional[float] + Maximum number of records to be returned (max limit: 100) + + offset : typing.Optional[float] + Offset used for pagination if the results have more than limit records - - limit: typing.Optional[float]. Maximum number of records to be returned (max limit: 100) + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - offset: typing.Optional[float]. Offset used for pagination if the results have more than limit records + Returns + ------- + SiteActivityLogResponse + A list of site activity logs - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -55,46 +61,22 @@ def list( ) """ _response = self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/activity_logs" - ), - params=jsonable_encoder( - remove_none_from_dict( - { - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/activity_logs", + method="GET", + params={"limit": limit, "offset": offset}, + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(SiteActivityLogResponse, _response.json()) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(SiteActivityLogResponse, _response.json()) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -116,15 +98,27 @@ async def list( """ Retrieve Activity Logs for a specific Site. Requires Site to be on an Enterprise plan.

Required scope | `site_activity:read` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site + + limit : typing.Optional[float] + Maximum number of records to be returned (max limit: 100) + + offset : typing.Optional[float] + Offset used for pagination if the results have more than limit records - - limit: typing.Optional[float]. Maximum number of records to be returned (max limit: 100) + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - offset: typing.Optional[float]. Offset used for pagination if the results have more than limit records + Returns + ------- + SiteActivityLogResponse + A list of site activity logs - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -135,46 +129,22 @@ async def list( ) """ _response = await self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/activity_logs" - ), - params=jsonable_encoder( - remove_none_from_dict( - { - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/activity_logs", + method="GET", + params={"limit": limit, "offset": offset}, + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(SiteActivityLogResponse, _response.json()) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(SiteActivityLogResponse, _response.json()) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/src/webflow/resources/sites/resources/scripts/client.py b/src/webflow/resources/sites/resources/scripts/client.py index bca1824..9470804 100644 --- a/src/webflow/resources/sites/resources/scripts/client.py +++ b/src/webflow/resources/sites/resources/scripts/client.py @@ -1,13 +1,12 @@ # This file was auto-generated by Fern from our API Definition. import typing -import urllib.parse from json.decoder import JSONDecodeError from .....core.api_error import ApiError from .....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from .....core.jsonable_encoder import jsonable_encoder -from .....core.remove_none_from_dict import remove_none_from_dict +from .....core.pydantic_utilities import pydantic_v1 from .....core.request_options import RequestOptions from .....errors.bad_request_error import BadRequestError from .....errors.internal_server_error import InternalServerError @@ -15,13 +14,9 @@ from .....errors.too_many_requests_error import TooManyRequestsError from .....errors.unauthorized_error import UnauthorizedError from .....types.list_custom_code_blocks import ListCustomCodeBlocks +from .....types.script_apply import ScriptApply from .....types.script_apply_list import ScriptApplyList -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -34,13 +29,23 @@ def get_custom_code( self, site_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> ScriptApplyList: """ - Get all registered scripts that have been applied to a specific Site.

Access to this endpoint requires a bearer token from a Data Client App. Required scope | `custom_code:read` + Get all registered scripts that have been applied to a specific Site.
Access to this endpoint requires a bearer token from a Data Client App.
Required scope | `custom_code:read` + + Parameters + ---------- + site_id : str + Unique identifier for a Site - Parameters: - - site_id: str. Unique identifier for a Site + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Returns + ------- + ScriptApplyList + Request was successful + + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -51,57 +56,63 @@ def get_custom_code( ) """ _response = self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/custom_code" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/custom_code", method="GET", request_options=request_options ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(ScriptApplyList, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(ScriptApplyList, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) def upsert_custom_code( - self, site_id: str, *, request: ScriptApplyList, request_options: typing.Optional[RequestOptions] = None + self, + site_id: str, + *, + scripts: typing.Optional[typing.Sequence[ScriptApply]] = OMIT, + last_updated: typing.Optional[str] = OMIT, + created_on: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, ) -> ScriptApplyList: """ - Add a registered script to a Site.

In order to use the Custom Code APIs for Sites and Pages, Custom Code Scripts must first be registered to a Site via the `registered_scripts` endpoints, and then applied to a Site or Page using the appropriate `custom_code` endpoints.

Access to this endpoint requires a bearer token from a Data Client App. Required scope | `custom_code:write` + Add a registered script to a Site.

In order to use the Custom Code APIs for Sites and Pages, Custom Code Scripts must first be registered to a Site via the `registered_scripts` endpoints, and then applied to a Site or Page using the appropriate `custom_code` endpoints.
Access to this endpoint requires a bearer token from a Data Client App.
Required scope | `custom_code:write` + + Parameters + ---------- + site_id : str + Unique identifier for a Site - Parameters: - - site_id: str. Unique identifier for a Site + scripts : typing.Optional[typing.Sequence[ScriptApply]] + A list of scripts applied to a Site or a Page - - request: ScriptApplyList. + last_updated : typing.Optional[str] + Date when the Site's scripts were last updated - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- - from webflow import ScriptApply, ScriptApplyList, ScriptApplyLocation + created_on : typing.Optional[str] + Date when the Site's scripts were created + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ScriptApplyList + Request was successful + + Examples + -------- + from webflow import ScriptApply, ScriptApplyLocation from webflow.client import Webflow client = Webflow( @@ -109,67 +120,41 @@ def upsert_custom_code( ) client.sites.scripts.upsert_custom_code( site_id="site_id", - request=ScriptApplyList( - scripts=[ - ScriptApply( - id="cms_slider", - location=ScriptApplyLocation.HEADER, - version="1.0.0", - attributes={"my-attribute": "some-value"}, - ), - ScriptApply( - id="alert", - location=ScriptApplyLocation.HEADER, - version="0.0.1", - ), - ScriptApply( - id="id", - location=ScriptApplyLocation.HEADER, - version="version", - ), - ], - ), + scripts=[ + ScriptApply( + id="cms_slider", + location=ScriptApplyLocation.HEADER, + version="1.0.0", + attributes={"my-attribute": "some-value"}, + ), + ScriptApply( + id="alert", + location=ScriptApplyLocation.HEADER, + version="0.0.1", + ), + ], ) """ _response = self._client_wrapper.httpx_client.request( - "PUT", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/custom_code" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/custom_code", + method="PUT", + json={"scripts": scripts, "lastUpdated": last_updated, "createdOn": created_on}, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(ScriptApplyList, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(ScriptApplyList, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -177,13 +162,22 @@ def upsert_custom_code( def delete_custom_code(self, site_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: """ - Delete the custom code block that an app created for a Site

Access to this endpoint requires a bearer token from a Data Client App. Required scope | `custom_code:write` + Delete the custom code block that an app created for a Site

Access to this endpoint requires a bearer token from a Data Client App.
Required scope | `custom_code:write` + + Parameters + ---------- + site_id : str + Unique identifier for a Site - Parameters: - - site_id: str. Unique identifier for a Site + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Returns + ------- + None + + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -194,38 +188,21 @@ def delete_custom_code(self, site_id: str, *, request_options: typing.Optional[R ) """ _response = self._client_wrapper.httpx_client.request( - "DELETE", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/custom_code" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/custom_code", method="DELETE", request_options=request_options ) - if 200 <= _response.status_code < 300: - return - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -240,17 +217,29 @@ def list_custom_code_blocks( request_options: typing.Optional[RequestOptions] = None, ) -> ListCustomCodeBlocks: """ - Get all instances of Custom Code applied to a Site or Pages.

Access to this endpoint requires a bearer token from a Data Client App. Required scope | `custom_code:read` + Get all instances of Custom Code applied to a Site or Pages.
Access to this endpoint requires a bearer token from a Data Client App.
Required scope | `custom_code:read` + + Parameters + ---------- + site_id : str + Unique identifier for a Site + + offset : typing.Optional[float] + Offset used for pagination if the results have more than limit records - Parameters: - - site_id: str. Unique identifier for a Site + limit : typing.Optional[float] + Maximum number of records to be returned (max limit: 100) - - offset: typing.Optional[float]. Offset used for pagination if the results have more than limit records + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - limit: typing.Optional[float]. Maximum number of records to be returned (max limit: 100) + Returns + ------- + ListCustomCodeBlocks + Request was successful - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -261,48 +250,24 @@ def list_custom_code_blocks( ) """ _response = self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/custom_code/blocks" - ), - params=jsonable_encoder( - remove_none_from_dict( - { - "offset": offset, - "limit": limit, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/custom_code/blocks", + method="GET", + params={"offset": offset, "limit": limit}, + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(ListCustomCodeBlocks, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(ListCustomCodeBlocks, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -317,13 +282,23 @@ async def get_custom_code( self, site_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> ScriptApplyList: """ - Get all registered scripts that have been applied to a specific Site.

Access to this endpoint requires a bearer token from a Data Client App. Required scope | `custom_code:read` + Get all registered scripts that have been applied to a specific Site.
Access to this endpoint requires a bearer token from a Data Client App.
Required scope | `custom_code:read` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ScriptApplyList + Request was successful + + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -334,57 +309,63 @@ async def get_custom_code( ) """ _response = await self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/custom_code" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/custom_code", method="GET", request_options=request_options ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(ScriptApplyList, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(ScriptApplyList, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) async def upsert_custom_code( - self, site_id: str, *, request: ScriptApplyList, request_options: typing.Optional[RequestOptions] = None + self, + site_id: str, + *, + scripts: typing.Optional[typing.Sequence[ScriptApply]] = OMIT, + last_updated: typing.Optional[str] = OMIT, + created_on: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, ) -> ScriptApplyList: """ - Add a registered script to a Site.

In order to use the Custom Code APIs for Sites and Pages, Custom Code Scripts must first be registered to a Site via the `registered_scripts` endpoints, and then applied to a Site or Page using the appropriate `custom_code` endpoints.

Access to this endpoint requires a bearer token from a Data Client App. Required scope | `custom_code:write` + Add a registered script to a Site.

In order to use the Custom Code APIs for Sites and Pages, Custom Code Scripts must first be registered to a Site via the `registered_scripts` endpoints, and then applied to a Site or Page using the appropriate `custom_code` endpoints.
Access to this endpoint requires a bearer token from a Data Client App.
Required scope | `custom_code:write` + + Parameters + ---------- + site_id : str + Unique identifier for a Site - Parameters: - - site_id: str. Unique identifier for a Site + scripts : typing.Optional[typing.Sequence[ScriptApply]] + A list of scripts applied to a Site or a Page - - request: ScriptApplyList. + last_updated : typing.Optional[str] + Date when the Site's scripts were last updated - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- - from webflow import ScriptApply, ScriptApplyList, ScriptApplyLocation + created_on : typing.Optional[str] + Date when the Site's scripts were created + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ScriptApplyList + Request was successful + + Examples + -------- + from webflow import ScriptApply, ScriptApplyLocation from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -392,67 +373,41 @@ async def upsert_custom_code( ) await client.sites.scripts.upsert_custom_code( site_id="site_id", - request=ScriptApplyList( - scripts=[ - ScriptApply( - id="cms_slider", - location=ScriptApplyLocation.HEADER, - version="1.0.0", - attributes={"my-attribute": "some-value"}, - ), - ScriptApply( - id="alert", - location=ScriptApplyLocation.HEADER, - version="0.0.1", - ), - ScriptApply( - id="id", - location=ScriptApplyLocation.HEADER, - version="version", - ), - ], - ), + scripts=[ + ScriptApply( + id="cms_slider", + location=ScriptApplyLocation.HEADER, + version="1.0.0", + attributes={"my-attribute": "some-value"}, + ), + ScriptApply( + id="alert", + location=ScriptApplyLocation.HEADER, + version="0.0.1", + ), + ], ) """ _response = await self._client_wrapper.httpx_client.request( - "PUT", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/custom_code" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/custom_code", + method="PUT", + json={"scripts": scripts, "lastUpdated": last_updated, "createdOn": created_on}, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(ScriptApplyList, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(ScriptApplyList, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -462,13 +417,22 @@ async def delete_custom_code( self, site_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> None: """ - Delete the custom code block that an app created for a Site

Access to this endpoint requires a bearer token from a Data Client App. Required scope | `custom_code:write` + Delete the custom code block that an app created for a Site

Access to this endpoint requires a bearer token from a Data Client App.
Required scope | `custom_code:write` + + Parameters + ---------- + site_id : str + Unique identifier for a Site - Parameters: - - site_id: str. Unique identifier for a Site + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Returns + ------- + None + + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -479,38 +443,21 @@ async def delete_custom_code( ) """ _response = await self._client_wrapper.httpx_client.request( - "DELETE", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/custom_code" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/custom_code", method="DELETE", request_options=request_options ) - if 200 <= _response.status_code < 300: - return - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -525,17 +472,29 @@ async def list_custom_code_blocks( request_options: typing.Optional[RequestOptions] = None, ) -> ListCustomCodeBlocks: """ - Get all instances of Custom Code applied to a Site or Pages.

Access to this endpoint requires a bearer token from a Data Client App. Required scope | `custom_code:read` + Get all instances of Custom Code applied to a Site or Pages.
Access to this endpoint requires a bearer token from a Data Client App.
Required scope | `custom_code:read` + + Parameters + ---------- + site_id : str + Unique identifier for a Site + + offset : typing.Optional[float] + Offset used for pagination if the results have more than limit records - Parameters: - - site_id: str. Unique identifier for a Site + limit : typing.Optional[float] + Maximum number of records to be returned (max limit: 100) - - offset: typing.Optional[float]. Offset used for pagination if the results have more than limit records + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - limit: typing.Optional[float]. Maximum number of records to be returned (max limit: 100) + Returns + ------- + ListCustomCodeBlocks + Request was successful - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -546,48 +505,24 @@ async def list_custom_code_blocks( ) """ _response = await self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/custom_code/blocks" - ), - params=jsonable_encoder( - remove_none_from_dict( - { - "offset": offset, - "limit": limit, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/custom_code/blocks", + method="GET", + params={"offset": offset, "limit": limit}, + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(ListCustomCodeBlocks, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(ListCustomCodeBlocks, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/src/webflow/resources/token/client.py b/src/webflow/resources/token/client.py index 9236d46..19a9083 100644 --- a/src/webflow/resources/token/client.py +++ b/src/webflow/resources/token/client.py @@ -1,24 +1,17 @@ # This file was auto-generated by Fern from our API Definition. import typing -import urllib.parse from json.decoder import JSONDecodeError from ...core.api_error import ApiError from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper -from ...core.jsonable_encoder import jsonable_encoder -from ...core.remove_none_from_dict import remove_none_from_dict +from ...core.pydantic_utilities import pydantic_v1 from ...core.request_options import RequestOptions from ...errors.forbidden_error import ForbiddenError from ...errors.unauthorized_error import UnauthorizedError from ...types.authorization import Authorization from ...types.authorized_user import AuthorizedUser -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - class TokenClient: def __init__(self, *, client_wrapper: SyncClientWrapper): @@ -28,9 +21,18 @@ def authorized_by(self, *, request_options: typing.Optional[RequestOptions] = No """ Information about the Authorized User

Required Scope | `authorized_user:read` - Parameters: - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AuthorizedUser + Request was successful + + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -39,30 +41,15 @@ def authorized_by(self, *, request_options: typing.Optional[RequestOptions] = No client.token.authorized_by() """ _response = self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "token/authorized_by"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + "token/authorized_by", method="GET", request_options=request_options ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(AuthorizedUser, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(AuthorizedUser, _response.json()) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -70,11 +57,20 @@ def authorized_by(self, *, request_options: typing.Optional[RequestOptions] = No def introspect(self, *, request_options: typing.Optional[RequestOptions] = None) -> Authorization: """ - Information about the authorization token

Access to this endpoint requires a bearer token from a Data Client App. + Information about the authorization token
Access to this endpoint requires a bearer token from a Data Client App.
+ + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + Authorization + Request was successful - Parameters: - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -83,28 +79,13 @@ def introspect(self, *, request_options: typing.Optional[RequestOptions] = None) client.token.introspect() """ _response = self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "token/introspect"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + "token/introspect", method="GET", request_options=request_options ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Authorization, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(Authorization, _response.json()) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -119,9 +100,18 @@ async def authorized_by(self, *, request_options: typing.Optional[RequestOptions """ Information about the Authorized User

Required Scope | `authorized_user:read` - Parameters: - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AuthorizedUser + Request was successful + + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -130,30 +120,15 @@ async def authorized_by(self, *, request_options: typing.Optional[RequestOptions await client.token.authorized_by() """ _response = await self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "token/authorized_by"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + "token/authorized_by", method="GET", request_options=request_options ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(AuthorizedUser, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(AuthorizedUser, _response.json()) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -161,11 +136,20 @@ async def authorized_by(self, *, request_options: typing.Optional[RequestOptions async def introspect(self, *, request_options: typing.Optional[RequestOptions] = None) -> Authorization: """ - Information about the authorization token

Access to this endpoint requires a bearer token from a Data Client App. + Information about the authorization token
Access to this endpoint requires a bearer token from a Data Client App.
+ + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + Authorization + Request was successful - Parameters: - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -174,28 +158,13 @@ async def introspect(self, *, request_options: typing.Optional[RequestOptions] = await client.token.introspect() """ _response = await self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "token/introspect"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + "token/introspect", method="GET", request_options=request_options ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Authorization, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(Authorization, _response.json()) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/src/webflow/resources/users/client.py b/src/webflow/resources/users/client.py index f3d62bf..08e8045 100644 --- a/src/webflow/resources/users/client.py +++ b/src/webflow/resources/users/client.py @@ -1,13 +1,12 @@ # This file was auto-generated by Fern from our API Definition. import typing -import urllib.parse from json.decoder import JSONDecodeError from ...core.api_error import ApiError from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ...core.jsonable_encoder import jsonable_encoder -from ...core.remove_none_from_dict import remove_none_from_dict +from ...core.pydantic_utilities import pydantic_v1 from ...core.request_options import RequestOptions from ...errors.bad_request_error import BadRequestError from ...errors.conflict_error import ConflictError @@ -21,11 +20,6 @@ from .types.users_list_request_sort import UsersListRequestSort from .types.users_update_request_data import UsersUpdateRequestData -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -46,20 +40,34 @@ def list( """ Get a list of users for a site

Required scope | `users:read` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site + + offset : typing.Optional[float] + Offset used for pagination if the results have more than limit records + + limit : typing.Optional[float] + Maximum number of records to be returned (max limit: 100) + + sort : typing.Optional[UsersListRequestSort] + Sort string to use when ordering users - - offset: typing.Optional[float]. Offset used for pagination if the results have more than limit records + Example(`CreatedOn`, `Email`, `Status`, `LastLogin`, `UpdatedOn`). - - limit: typing.Optional[float]. Maximum number of records to be returned (max limit: 100) + Can be prefixed with a `-` to reverse the sort (ex. `-CreatedOn`) - - sort: typing.Optional[UsersListRequestSort]. Sort string to use when ordering users + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - Example(`CreatedOn`, `Email`, `Status`, `LastLogin`, `UpdatedOn`). + Returns + ------- + UserList + Request was successful - Can be prefixed with a `-` to reverse the sort (ex. `-CreatedOn`) - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -70,49 +78,26 @@ def list( ) """ _response = self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/users"), - params=jsonable_encoder( - remove_none_from_dict( - { - "offset": offset, - "limit": limit, - "sort": sort, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/users", + method="GET", + params={"offset": offset, "limit": limit, "sort": sort}, + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(UserList, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(UserList, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -122,13 +107,24 @@ def get(self, site_id: str, user_id: str, *, request_options: typing.Optional[Re """ Get a User by ID

Required scope | `users:read` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site + + user_id : str + Unique identifier for a User - - user_id: str. Unique identifier for a User + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Returns + ------- + User + Request was successful + + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -140,41 +136,25 @@ def get(self, site_id: str, user_id: str, *, request_options: typing.Optional[Re ) """ _response = self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"sites/{jsonable_encoder(site_id)}/users/{jsonable_encoder(user_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/users/{jsonable_encoder(user_id)}", + method="GET", + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(User, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(User, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -184,13 +164,23 @@ def delete(self, site_id: str, user_id: str, *, request_options: typing.Optional """ Delete a User by ID

Required scope | `users:write` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site - - user_id: str. Unique identifier for a User + user_id : str + Unique identifier for a User - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + None + + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -202,41 +192,25 @@ def delete(self, site_id: str, user_id: str, *, request_options: typing.Optional ) """ _response = self._client_wrapper.httpx_client.request( - "DELETE", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"sites/{jsonable_encoder(site_id)}/users/{jsonable_encoder(user_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/users/{jsonable_encoder(user_id)}", + method="DELETE", + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -256,17 +230,30 @@ def update( - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site + + user_id : str + Unique identifier for a User + + data : typing.Optional[UsersUpdateRequestData] - - user_id: str. Unique identifier for a User + access_groups : typing.Optional[typing.Sequence[str]] + An array of access group slugs. Access groups are assigned to the user as type `admin` and the user remains in the group until removed. - - data: typing.Optional[UsersUpdateRequestData]. - - access_groups: typing.Optional[typing.Sequence[str]]. An array of access group slugs. Access groups are assigned to the user as type `admin` and the user remains in the group until removed. + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Returns + ------- + User + Request was successful + + Examples + -------- from webflow import UsersUpdateRequestData from webflow.client import Webflow @@ -281,56 +268,31 @@ def update( accept_privacy=False, accept_communications=False, ), - access_groups=["webflowers", "platinum", "free-tier", "accessGroups"], + access_groups=["webflowers", "platinum", "free-tier"], ) """ - _request: typing.Dict[str, typing.Any] = {} - if data is not OMIT: - _request["data"] = data - if access_groups is not OMIT: - _request["accessGroups"] = access_groups _response = self._client_wrapper.httpx_client.request( - "PATCH", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"sites/{jsonable_encoder(site_id)}/users/{jsonable_encoder(user_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/users/{jsonable_encoder(user_id)}", + method="PATCH", + json={"data": data, "accessGroups": access_groups}, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(User, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(User, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -347,15 +309,28 @@ def invite( """ Create and invite a user with an email address. The user will be sent and invite via email, which they will need to accept in order to join paid Access Groups.

Required scope | `users:write` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site + + email : str + Email address of user to send invite to + + access_groups : typing.Optional[typing.Sequence[str]] + An array of access group slugs. Access groups are assigned to the user as type `admin` and the user remains in the group until removed. + - - email: str. Email address of user to send invite to + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - access_groups: typing.Optional[typing.Sequence[str]]. An array of access group slugs. Access groups are assigned to the user as type `admin` and the user remains in the group until removed. + Returns + ------- + User + Request was successful - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -364,55 +339,33 @@ def invite( client.users.invite( site_id="site_id", email="some.one@home.com", - access_groups=["webflowers", "accessGroups"], + access_groups=["webflowers"], ) """ - _request: typing.Dict[str, typing.Any] = {"email": email} - if access_groups is not OMIT: - _request["accessGroups"] = access_groups _response = self._client_wrapper.httpx_client.request( - "POST", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/users/invite" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/users/invite", + method="POST", + json={"email": email, "accessGroups": access_groups}, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(User, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 409: - raise ConflictError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(User, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 409: + raise ConflictError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -435,20 +388,34 @@ async def list( """ Get a list of users for a site

Required scope | `users:read` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site - - offset: typing.Optional[float]. Offset used for pagination if the results have more than limit records + offset : typing.Optional[float] + Offset used for pagination if the results have more than limit records - - limit: typing.Optional[float]. Maximum number of records to be returned (max limit: 100) + limit : typing.Optional[float] + Maximum number of records to be returned (max limit: 100) - - sort: typing.Optional[UsersListRequestSort]. Sort string to use when ordering users + sort : typing.Optional[UsersListRequestSort] + Sort string to use when ordering users - Example(`CreatedOn`, `Email`, `Status`, `LastLogin`, `UpdatedOn`). + Example(`CreatedOn`, `Email`, `Status`, `LastLogin`, `UpdatedOn`). - Can be prefixed with a `-` to reverse the sort (ex. `-CreatedOn`) - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Can be prefixed with a `-` to reverse the sort (ex. `-CreatedOn`) + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + UserList + Request was successful + + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -459,49 +426,26 @@ async def list( ) """ _response = await self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/users"), - params=jsonable_encoder( - remove_none_from_dict( - { - "offset": offset, - "limit": limit, - "sort": sort, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/users", + method="GET", + params={"offset": offset, "limit": limit, "sort": sort}, + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(UserList, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(UserList, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -511,13 +455,24 @@ async def get(self, site_id: str, user_id: str, *, request_options: typing.Optio """ Get a User by ID

Required scope | `users:read` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site + + user_id : str + Unique identifier for a User + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - user_id: str. Unique identifier for a User + Returns + ------- + User + Request was successful - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -529,41 +484,25 @@ async def get(self, site_id: str, user_id: str, *, request_options: typing.Optio ) """ _response = await self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"sites/{jsonable_encoder(site_id)}/users/{jsonable_encoder(user_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/users/{jsonable_encoder(user_id)}", + method="GET", + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(User, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(User, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -575,13 +514,23 @@ async def delete( """ Delete a User by ID

Required scope | `users:write` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site + + user_id : str + Unique identifier for a User - - user_id: str. Unique identifier for a User + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Returns + ------- + None + + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -593,41 +542,25 @@ async def delete( ) """ _response = await self._client_wrapper.httpx_client.request( - "DELETE", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"sites/{jsonable_encoder(site_id)}/users/{jsonable_encoder(user_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/users/{jsonable_encoder(user_id)}", + method="DELETE", + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -647,17 +580,30 @@ async def update( - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site + + user_id : str + Unique identifier for a User + + data : typing.Optional[UsersUpdateRequestData] + + access_groups : typing.Optional[typing.Sequence[str]] + An array of access group slugs. Access groups are assigned to the user as type `admin` and the user remains in the group until removed. - - user_id: str. Unique identifier for a User - - data: typing.Optional[UsersUpdateRequestData]. + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - access_groups: typing.Optional[typing.Sequence[str]]. An array of access group slugs. Access groups are assigned to the user as type `admin` and the user remains in the group until removed. + Returns + ------- + User + Request was successful - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow import UsersUpdateRequestData from webflow.client import AsyncWebflow @@ -672,56 +618,31 @@ async def update( accept_privacy=False, accept_communications=False, ), - access_groups=["webflowers", "platinum", "free-tier", "accessGroups"], + access_groups=["webflowers", "platinum", "free-tier"], ) """ - _request: typing.Dict[str, typing.Any] = {} - if data is not OMIT: - _request["data"] = data - if access_groups is not OMIT: - _request["accessGroups"] = access_groups _response = await self._client_wrapper.httpx_client.request( - "PATCH", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"sites/{jsonable_encoder(site_id)}/users/{jsonable_encoder(user_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/users/{jsonable_encoder(user_id)}", + method="PATCH", + json={"data": data, "accessGroups": access_groups}, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(User, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(User, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -738,15 +659,28 @@ async def invite( """ Create and invite a user with an email address. The user will be sent and invite via email, which they will need to accept in order to join paid Access Groups.

Required scope | `users:write` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site - - email: str. Email address of user to send invite to + email : str + Email address of user to send invite to - - access_groups: typing.Optional[typing.Sequence[str]]. An array of access group slugs. Access groups are assigned to the user as type `admin` and the user remains in the group until removed. + access_groups : typing.Optional[typing.Sequence[str]] + An array of access group slugs. Access groups are assigned to the user as type `admin` and the user remains in the group until removed. - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + User + Request was successful + + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -755,55 +689,33 @@ async def invite( await client.users.invite( site_id="site_id", email="some.one@home.com", - access_groups=["webflowers", "accessGroups"], + access_groups=["webflowers"], ) """ - _request: typing.Dict[str, typing.Any] = {"email": email} - if access_groups is not OMIT: - _request["accessGroups"] = access_groups _response = await self._client_wrapper.httpx_client.request( - "POST", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/users/invite" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/users/invite", + method="POST", + json={"email": email, "accessGroups": access_groups}, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(User, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 403: - raise ForbiddenError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 409: - raise ConflictError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(User, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 409: + raise ConflictError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/src/webflow/resources/users/types/users_update_request_data.py b/src/webflow/resources/users/types/users_update_request_data.py index cb99ef6..c765cea 100644 --- a/src/webflow/resources/users/types/users_update_request_data.py +++ b/src/webflow/resources/users/types/users_update_request_data.py @@ -4,36 +4,41 @@ import typing from ....core.datetime_utils import serialize_datetime +from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - - -class UsersUpdateRequestData(pydantic.BaseModel): - name: typing.Optional[str] = pydantic.Field(default=None, description="The name of the user") - accept_privacy: typing.Optional[bool] = pydantic.Field( - alias="accept-privacy", - default=None, - description="Boolean indicating if the user has accepted the privacy policy", - ) - accept_communications: typing.Optional[bool] = pydantic.Field( - alias="accept-communications", - default=None, - description="Boolean indicating if the user has accepted to receive communications", - ) + +class UsersUpdateRequestData(pydantic_v1.BaseModel): + name: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + The name of the user + """ + + accept_privacy: typing.Optional[bool] = pydantic_v1.Field(alias="accept-privacy", default=None) + """ + Boolean indicating if the user has accepted the privacy policy + """ + + accept_communications: typing.Optional[bool] = pydantic_v1.Field(alias="accept-communications", default=None) + """ + Boolean indicating if the user has accepted to receive communications + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/resources/webhooks/client.py b/src/webflow/resources/webhooks/client.py index 0309b13..9225c18 100644 --- a/src/webflow/resources/webhooks/client.py +++ b/src/webflow/resources/webhooks/client.py @@ -1,13 +1,12 @@ # This file was auto-generated by Fern from our API Definition. import typing -import urllib.parse from json.decoder import JSONDecodeError from ...core.api_error import ApiError from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ...core.jsonable_encoder import jsonable_encoder -from ...core.remove_none_from_dict import remove_none_from_dict +from ...core.pydantic_utilities import pydantic_v1 from ...core.request_options import RequestOptions from ...errors.bad_request_error import BadRequestError from ...errors.internal_server_error import InternalServerError @@ -18,11 +17,6 @@ from ...types.webhook import Webhook from ...types.webhook_list import WebhookList -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -35,11 +29,21 @@ def list(self, site_id: str, *, request_options: typing.Optional[RequestOptions] """ List all App-created Webhooks registered for a given site

Required scope | `sites:read` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + WebhookList + Request was successful - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -50,38 +54,21 @@ def list(self, site_id: str, *, request_options: typing.Optional[RequestOptions] ) """ _response = self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/webhooks" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/webhooks", method="GET", request_options=request_options ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(WebhookList, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(WebhookList, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -97,20 +84,34 @@ def create( request_options: typing.Optional[RequestOptions] = None, ) -> Webhook: """ - Create a new Webhook, to be notified when Webflow resources change. Limit of 75 registrations per `triggerType`, per site.

Access to this endpoint requires a bearer token from a Data Client App. The only exceptions are for creating webhooks with `site_publish` or `form_submission` triggers, which can be done with Site Tokens
Required scope | `sites:write` + Create a new Webhook, to be notified when Webflow resources change. Limit of 75 registrations per `triggerType`, per site.
Access to this endpoint requires a bearer token from a Data Client App.
Required scope | `sites:write` + + Parameters + ---------- + site_id : str + Unique identifier for a Site + + trigger_type : TriggerType + + url : str + The server URI that Webflow will call when your Webhook is triggered - Parameters: - - site_id: str. Unique identifier for a Site - - trigger_type: TriggerType. + filter : typing.Optional[typing.Dict[str, typing.Any]] + Filter for selecting which events you want Webhooks to be triggered for. + ** Only available for `form_submission` trigger types. ** - - url: str. The server URI that Webflow will call when your Webhook is triggered - - filter: typing.Optional[typing.Dict[str, typing.Any]]. Filter for selecting which events you want Webhooks to be triggered for. - ** Only available for `form_submission` trigger types. ** + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Returns + ------- + Webhook + Request was successful + + Examples + -------- from webflow import TriggerType from webflow.client import Webflow @@ -123,48 +124,26 @@ def create( url="https://api.mydomain.com/webhook", ) """ - _request: typing.Dict[str, typing.Any] = {"triggerType": trigger_type, "url": url} - if filter is not OMIT: - _request["filter"] = filter _response = self._client_wrapper.httpx_client.request( - "POST", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/webhooks" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/webhooks", + method="POST", + json={"triggerType": trigger_type, "url": url, "filter": filter}, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Webhook, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(Webhook, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -174,11 +153,21 @@ def get(self, webhook_id: str, *, request_options: typing.Optional[RequestOption """ Get a specific Webhook instance - Parameters: - - webhook_id: str. Unique identifier for a Webhook + Parameters + ---------- + webhook_id : str + Unique identifier for a Webhook + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + Webhook + Request was successful - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -189,36 +178,21 @@ def get(self, webhook_id: str, *, request_options: typing.Optional[RequestOption ) """ _response = self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"webhooks/{jsonable_encoder(webhook_id)}"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"webhooks/{jsonable_encoder(webhook_id)}", method="GET", request_options=request_options ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Webhook, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(Webhook, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -228,11 +202,20 @@ def delete(self, webhook_id: str, *, request_options: typing.Optional[RequestOpt """ Remove a Webhook - Parameters: - - webhook_id: str. Unique identifier for a Webhook + Parameters + ---------- + webhook_id : str + Unique identifier for a Webhook + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + None - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import Webflow client = Webflow( @@ -243,36 +226,21 @@ def delete(self, webhook_id: str, *, request_options: typing.Optional[RequestOpt ) """ _response = self._client_wrapper.httpx_client.request( - "DELETE", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"webhooks/{jsonable_encoder(webhook_id)}"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"webhooks/{jsonable_encoder(webhook_id)}", method="DELETE", request_options=request_options ) - if 200 <= _response.status_code < 300: - return - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -287,11 +255,21 @@ async def list(self, site_id: str, *, request_options: typing.Optional[RequestOp """ List all App-created Webhooks registered for a given site

Required scope | `sites:read` - Parameters: - - site_id: str. Unique identifier for a Site + Parameters + ---------- + site_id : str + Unique identifier for a Site - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + WebhookList + Request was successful + + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -302,38 +280,21 @@ async def list(self, site_id: str, *, request_options: typing.Optional[RequestOp ) """ _response = await self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/webhooks" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/webhooks", method="GET", request_options=request_options ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(WebhookList, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(WebhookList, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -349,20 +310,34 @@ async def create( request_options: typing.Optional[RequestOptions] = None, ) -> Webhook: """ - Create a new Webhook, to be notified when Webflow resources change. Limit of 75 registrations per `triggerType`, per site.

Access to this endpoint requires a bearer token from a Data Client App. The only exceptions are for creating webhooks with `site_publish` or `form_submission` triggers, which can be done with Site Tokens
Required scope | `sites:write` + Create a new Webhook, to be notified when Webflow resources change. Limit of 75 registrations per `triggerType`, per site.
Access to this endpoint requires a bearer token from a Data Client App.
Required scope | `sites:write` + + Parameters + ---------- + site_id : str + Unique identifier for a Site + + trigger_type : TriggerType + + url : str + The server URI that Webflow will call when your Webhook is triggered - Parameters: - - site_id: str. Unique identifier for a Site - - trigger_type: TriggerType. + filter : typing.Optional[typing.Dict[str, typing.Any]] + Filter for selecting which events you want Webhooks to be triggered for. + ** Only available for `form_submission` trigger types. ** - - url: str. The server URI that Webflow will call when your Webhook is triggered - - filter: typing.Optional[typing.Dict[str, typing.Any]]. Filter for selecting which events you want Webhooks to be triggered for. - ** Only available for `form_submission` trigger types. ** + request_options : typing.Optional[RequestOptions] + Request-specific configuration. - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Returns + ------- + Webhook + Request was successful + + Examples + -------- from webflow import TriggerType from webflow.client import AsyncWebflow @@ -375,48 +350,26 @@ async def create( url="https://api.mydomain.com/webhook", ) """ - _request: typing.Dict[str, typing.Any] = {"triggerType": trigger_type, "url": url} - if filter is not OMIT: - _request["filter"] = filter _response = await self._client_wrapper.httpx_client.request( - "POST", - urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"sites/{jsonable_encoder(site_id)}/webhooks" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"sites/{jsonable_encoder(site_id)}/webhooks", + method="POST", + json={"triggerType": trigger_type, "url": url, "filter": filter}, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Webhook, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(Webhook, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -426,11 +379,21 @@ async def get(self, webhook_id: str, *, request_options: typing.Optional[Request """ Get a specific Webhook instance - Parameters: - - webhook_id: str. Unique identifier for a Webhook + Parameters + ---------- + webhook_id : str + Unique identifier for a Webhook + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + Webhook + Request was successful - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -441,36 +404,21 @@ async def get(self, webhook_id: str, *, request_options: typing.Optional[Request ) """ _response = await self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"webhooks/{jsonable_encoder(webhook_id)}"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"webhooks/{jsonable_encoder(webhook_id)}", method="GET", request_options=request_options ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(Webhook, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(Webhook, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -480,11 +428,20 @@ async def delete(self, webhook_id: str, *, request_options: typing.Optional[Requ """ Remove a Webhook - Parameters: - - webhook_id: str. Unique identifier for a Webhook + Parameters + ---------- + webhook_id : str + Unique identifier for a Webhook + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + None - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- + Examples + -------- from webflow.client import AsyncWebflow client = AsyncWebflow( @@ -495,36 +452,21 @@ async def delete(self, webhook_id: str, *, request_options: typing.Optional[Requ ) """ _response = await self._client_wrapper.httpx_client.request( - "DELETE", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"webhooks/{jsonable_encoder(webhook_id)}"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else 60, + f"webhooks/{jsonable_encoder(webhook_id)}", method="DELETE", request_options=request_options ) - if 200 <= _response.status_code < 300: - return - if _response.status_code == 400: - raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 429: - raise TooManyRequestsError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore try: + if 200 <= _response.status_code < 300: + return + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 429: + raise TooManyRequestsError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/src/webflow/types/__init__.py b/src/webflow/types/__init__.py index dc0bb64..16b5e7c 100644 --- a/src/webflow/types/__init__.py +++ b/src/webflow/types/__init__.py @@ -14,6 +14,7 @@ from .authorization_authorization import AuthorizationAuthorization from .authorization_authorization_authorized_to import AuthorizationAuthorizationAuthorizedTo from .authorized_user import AuthorizedUser +from .bad_request_error_body import BadRequestErrorBody from .collection import Collection from .collection_item import CollectionItem from .collection_item_field_data import CollectionItemFieldData @@ -21,9 +22,11 @@ from .collection_item_list_pagination import CollectionItemListPagination from .collection_list import CollectionList from .collection_list_array_item import CollectionListArrayItem +from .conflict_error_body import ConflictErrorBody from .custom_code_block import CustomCodeBlock from .custom_code_block_type import CustomCodeBlockType -from .custom_code_response import CustomCodeResponse +from .custom_code_hosted_response import CustomCodeHostedResponse +from .custom_code_inline_response import CustomCodeInlineResponse from .dom import Dom from .domain import Domain from .domains import Domains @@ -33,6 +36,7 @@ from .error_details_item import ErrorDetailsItem from .field import Field from .field_type import FieldType +from .forbidden_error_body import ForbiddenErrorBody from .form import Form from .form_field import FormField from .form_field_value import FormFieldValue @@ -46,6 +50,8 @@ from .inventory_item import InventoryItem from .inventory_item_inventory_type import InventoryItemInventoryType from .list_custom_code_blocks import ListCustomCodeBlocks +from .locale import Locale +from .locales import Locales from .missing_scopes import MissingScopes from .no_domains import NoDomains from .node import Node @@ -71,6 +77,9 @@ from .order_totals_extras_item import OrderTotalsExtrasItem from .order_totals_extras_item_type import OrderTotalsExtrasItemType from .page import Page +from .page_details import PageDetails +from .page_details_open_graph import PageDetailsOpenGraph +from .page_details_seo import PageDetailsSeo from .page_list import PageList from .page_open_graph import PageOpenGraph from .page_seo import PageSeo @@ -93,12 +102,15 @@ from .site_activity_log_item_resource_operation import SiteActivityLogItemResourceOperation from .site_activity_log_item_user import SiteActivityLogItemUser from .site_activity_log_response import SiteActivityLogResponse +from .sites import Sites from .sku import Sku from .sku_field_data import SkuFieldData from .sku_field_data_compare_at_price import SkuFieldDataCompareAtPrice from .sku_field_data_ec_sku_billing_method import SkuFieldDataEcSkuBillingMethod from .sku_field_data_ec_sku_subscription_plan import SkuFieldDataEcSkuSubscriptionPlan from .sku_field_data_ec_sku_subscription_plan_interval import SkuFieldDataEcSkuSubscriptionPlanInterval +from .sku_field_data_ec_sku_subscription_plan_plans_item import SkuFieldDataEcSkuSubscriptionPlanPlansItem +from .sku_field_data_ec_sku_subscription_plan_plans_item_status import SkuFieldDataEcSkuSubscriptionPlanPlansItemStatus from .sku_field_data_price import SkuFieldDataPrice from .sku_property_list import SkuPropertyList from .sku_property_list_enum_item import SkuPropertyListEnumItem @@ -136,6 +148,7 @@ "AuthorizationAuthorization", "AuthorizationAuthorizationAuthorizedTo", "AuthorizedUser", + "BadRequestErrorBody", "Collection", "CollectionItem", "CollectionItemFieldData", @@ -143,9 +156,11 @@ "CollectionItemListPagination", "CollectionList", "CollectionListArrayItem", + "ConflictErrorBody", "CustomCodeBlock", "CustomCodeBlockType", - "CustomCodeResponse", + "CustomCodeHostedResponse", + "CustomCodeInlineResponse", "Dom", "Domain", "Domains", @@ -155,6 +170,7 @@ "ErrorDetailsItem", "Field", "FieldType", + "ForbiddenErrorBody", "Form", "FormField", "FormFieldValue", @@ -168,6 +184,8 @@ "InventoryItem", "InventoryItemInventoryType", "ListCustomCodeBlocks", + "Locale", + "Locales", "MissingScopes", "NoDomains", "Node", @@ -193,6 +211,9 @@ "OrderTotalsExtrasItem", "OrderTotalsExtrasItemType", "Page", + "PageDetails", + "PageDetailsOpenGraph", + "PageDetailsSeo", "PageList", "PageOpenGraph", "PageSeo", @@ -215,12 +236,15 @@ "SiteActivityLogItemResourceOperation", "SiteActivityLogItemUser", "SiteActivityLogResponse", + "Sites", "Sku", "SkuFieldData", "SkuFieldDataCompareAtPrice", "SkuFieldDataEcSkuBillingMethod", "SkuFieldDataEcSkuSubscriptionPlan", "SkuFieldDataEcSkuSubscriptionPlanInterval", + "SkuFieldDataEcSkuSubscriptionPlanPlansItem", + "SkuFieldDataEcSkuSubscriptionPlanPlansItemStatus", "SkuFieldDataPrice", "SkuPropertyList", "SkuPropertyListEnumItem", diff --git a/src/webflow/types/access_group.py b/src/webflow/types/access_group.py index 5e07de0..d0b56f3 100644 --- a/src/webflow/types/access_group.py +++ b/src/webflow/types/access_group.py @@ -4,39 +4,51 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - - -class AccessGroup(pydantic.BaseModel): - id: typing.Optional[str] = pydantic.Field(default=None, description="Unique identifier for the Access Group") - name: typing.Optional[str] = pydantic.Field(default=None, description="Name of the the Access Group") - short_id: typing.Optional[str] = pydantic.Field( - alias="shortId", - default=None, - description="Shortened unique identifier based on name, optimized for its use in the user’s JWT", - ) - slug: typing.Optional[str] = pydantic.Field( - default=None, - description="Shortened unique identifier based on name, optimized for human readability and public API use", - ) - created_on: typing.Optional[dt.datetime] = pydantic.Field( - alias="createdOn", default=None, description="The date the Access Group was created" - ) + +class AccessGroup(pydantic_v1.BaseModel): + id: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + Unique identifier for the Access Group + """ + + name: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + Name of the the Access Group + """ + + short_id: typing.Optional[str] = pydantic_v1.Field(alias="shortId", default=None) + """ + Shortened unique identifier based on name, optimized for its use in the user’s JWT + """ + + slug: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + Shortened unique identifier based on name, optimized for human readability and public API use + """ + + created_on: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="createdOn", default=None) + """ + The date the Access Group was created + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/access_group_list.py b/src/webflow/types/access_group_list.py index aa36c97..a215c84 100644 --- a/src/webflow/types/access_group_list.py +++ b/src/webflow/types/access_group_list.py @@ -4,39 +4,56 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .access_group import AccessGroup -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class AccessGroupList(pydantic.BaseModel): +class AccessGroupList(pydantic_v1.BaseModel): """ The list access groups results """ - count: typing.Optional[float] = pydantic.Field(default=None, description="Number of access groups returned") - limit: typing.Optional[float] = pydantic.Field(default=None, description="The limit specified in the request") - offset: typing.Optional[float] = pydantic.Field(default=None, description="The offset specified for pagination") - total: typing.Optional[float] = pydantic.Field( - default=None, description="Total number of access groups in the collection" - ) - access_groups: typing.Optional[typing.List[AccessGroup]] = pydantic.Field( - alias="accessGroups", default=None, description="List of Site Access Groups" - ) + count: typing.Optional[float] = pydantic_v1.Field(default=None) + """ + Number of access groups returned + """ + + limit: typing.Optional[float] = pydantic_v1.Field(default=None) + """ + The limit specified in the request + """ + + offset: typing.Optional[float] = pydantic_v1.Field(default=None) + """ + The offset specified for pagination + """ + + total: typing.Optional[float] = pydantic_v1.Field(default=None) + """ + Total number of access groups in the collection + """ + + access_groups: typing.Optional[typing.List[AccessGroup]] = pydantic_v1.Field(alias="accessGroups", default=None) + """ + List of Site Access Groups + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/asset.py b/src/webflow/types/asset.py index 0d80162..d76f5ed 100644 --- a/src/webflow/types/asset.py +++ b/src/webflow/types/asset.py @@ -4,36 +4,56 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .asset_variant import AssetVariant -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - - -class Asset(pydantic.BaseModel): - id: typing.Optional[str] = pydantic.Field(default=None, description="Unique identifier for this asset") - content_type: typing.Optional[str] = pydantic.Field( - alias="contentType", default=None, description="File format type" - ) - size: typing.Optional[int] = pydantic.Field(default=None, description="size in bytes") - site_id: typing.Optional[str] = pydantic.Field( - alias="siteId", default=None, description="Unique identifier for the site that hosts this asset" - ) - hosted_url: typing.Optional[str] = pydantic.Field(alias="hostedUrl", default=None, description="Link to the asset") - original_file_name: typing.Optional[str] = pydantic.Field( - alias="originalFileName", default=None, description="Original file name at the time of upload" - ) - display_name: typing.Optional[str] = pydantic.Field( - alias="displayName", default=None, description="Display name of the asset" - ) - last_updated: typing.Optional[dt.datetime] = pydantic.Field( - alias="lastUpdated", default=None, description="Date the asset metadata was last updated" - ) - created_on: typing.Optional[dt.datetime] = pydantic.Field( - alias="createdOn", default=None, description="Date the asset metadata was created" - ) + +class Asset(pydantic_v1.BaseModel): + id: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + Unique identifier for this asset + """ + + original_file_name: typing.Optional[str] = pydantic_v1.Field(alias="originalFileName", default=None) + """ + Original file name at the time of upload + """ + + display_name: typing.Optional[str] = pydantic_v1.Field(alias="displayName", default=None) + """ + Display name of the asset + """ + + content_type: typing.Optional[str] = pydantic_v1.Field(alias="contentType", default=None) + """ + File format type + """ + + size: typing.Optional[int] = pydantic_v1.Field(default=None) + """ + size in bytes + """ + + site_id: typing.Optional[str] = pydantic_v1.Field(alias="siteId", default=None) + """ + Unique identifier for the site that hosts this asset + """ + + created_on: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="createdOn", default=None) + """ + Date the asset metadata was created + """ + + last_updated: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="lastUpdated", default=None) + """ + Date the asset metadata was last updated + """ + + hosted_url: typing.Optional[str] = pydantic_v1.Field(alias="hostedUrl", default=None) + """ + Link to the asset + """ + variants: typing.Optional[typing.List[AssetVariant]] = None def json(self, **kwargs: typing.Any) -> str: @@ -41,11 +61,17 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/asset_folder.py b/src/webflow/types/asset_folder.py index 130b755..2406d37 100644 --- a/src/webflow/types/asset_folder.py +++ b/src/webflow/types/asset_folder.py @@ -4,48 +4,65 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class AssetFolder(pydantic.BaseModel): +class AssetFolder(pydantic_v1.BaseModel): """ Asset Folder details """ - display_name: typing.Optional[str] = pydantic.Field( - alias="displayName", default=None, description="User visible name for the Asset Folder" - ) - id: typing.Optional[str] = pydantic.Field(default=None, description="Unique identifier for the Asset Folder") - parent_folder: typing.Optional[str] = pydantic.Field( - alias="parentFolder", default=None, description="Pointer to parent Asset Folder (or null if root)" - ) - assets: typing.Optional[typing.List[str]] = pydantic.Field( - default=None, description="Array of Asset instances in the folder" - ) - site_id: typing.Optional[str] = pydantic.Field( - alias="siteId", default=None, description="The unique id of the site the Asset Folder belongs to" - ) - created_on: typing.Optional[dt.datetime] = pydantic.Field( - alias="createdOn", default=None, description="Date that the Asset Folder was created on" - ) - last_updated: typing.Optional[dt.datetime] = pydantic.Field( - alias="lastUpdated", default=None, description="Date that the Asset Folder was last updated on" - ) + id: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + Unique identifier for the Asset Folder + """ + + display_name: typing.Optional[str] = pydantic_v1.Field(alias="displayName", default=None) + """ + User visible name for the Asset Folder + """ + + parent_folder: typing.Optional[str] = pydantic_v1.Field(alias="parentFolder", default=None) + """ + Pointer to parent Asset Folder (or null if root) + """ + + assets: typing.Optional[typing.List[str]] = pydantic_v1.Field(default=None) + """ + Array of Asset instances in the folder + """ + + site_id: typing.Optional[str] = pydantic_v1.Field(alias="siteId", default=None) + """ + The unique id of the site the Asset Folder belongs to + """ + + created_on: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="createdOn", default=None) + """ + Date that the Asset Folder was created on + """ + + last_updated: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="lastUpdated", default=None) + """ + Date that the Asset Folder was last updated on + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/asset_folder_list.py b/src/webflow/types/asset_folder_list.py index 89e533d..0ed82b6 100644 --- a/src/webflow/types/asset_folder_list.py +++ b/src/webflow/types/asset_folder_list.py @@ -4,23 +4,21 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .asset_folder import AssetFolder from .pagination import Pagination -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class AssetFolderList(pydantic.BaseModel): +class AssetFolderList(pydantic_v1.BaseModel): """ The Asset Folders object """ - asset_folders: typing.Optional[typing.List[AssetFolder]] = pydantic.Field( - alias="assetFolders", default=None, description="A list of Asset folders" - ) + asset_folders: typing.Optional[typing.List[AssetFolder]] = pydantic_v1.Field(alias="assetFolders", default=None) + """ + A list of Asset folders + """ + pagination: typing.Optional[Pagination] = None def json(self, **kwargs: typing.Any) -> str: @@ -28,11 +26,17 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/asset_upload.py b/src/webflow/types/asset_upload.py index 299f032..cea12b5 100644 --- a/src/webflow/types/asset_upload.py +++ b/src/webflow/types/asset_upload.py @@ -4,50 +4,65 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .asset_upload_upload_details import AssetUploadUploadDetails -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore +class AssetUpload(pydantic_v1.BaseModel): + upload_details: typing.Optional[AssetUploadUploadDetails] = pydantic_v1.Field(alias="uploadDetails", default=None) + """ + Metadata for uploading the asset binary + """ -class AssetUpload(pydantic.BaseModel): - upload_details: typing.Optional[AssetUploadUploadDetails] = pydantic.Field( - alias="uploadDetails", default=None, description="Metadata for uploading the asset binary" - ) + content_type: typing.Optional[str] = pydantic_v1.Field(alias="contentType", default=None) id: typing.Optional[str] = None - content_type: typing.Optional[str] = pydantic.Field(alias="contentType", default=None) - parent_folder: typing.Optional[str] = pydantic.Field( - alias="parentFolder", default=None, description="Parent folder for the asset" - ) - hosted_url: typing.Optional[str] = pydantic.Field( - alias="hostedUrl", default=None, description="Represents the link to the asset" - ) - upload_url: typing.Optional[str] = pydantic.Field(alias="uploadUrl", default=None) - asset_url: typing.Optional[str] = pydantic.Field(alias="assetUrl", default=None, description="S3 link to the asset") - original_file_name: typing.Optional[str] = pydantic.Field( - alias="originalFileName", - default=None, - description="Original file name when uploaded. If not specified at time of upload, it may be extracted from the raw file name", - ) - last_updated: typing.Optional[dt.datetime] = pydantic.Field( - alias="lastUpdated", default=None, description="Date the asset metadata was last updated" - ) - created_on: typing.Optional[dt.datetime] = pydantic.Field( - alias="createdOn", default=None, description="Date the asset metadata was created" - ) + parent_folder: typing.Optional[str] = pydantic_v1.Field(alias="parentFolder", default=None) + """ + Parent folder for the asset + """ + + upload_url: typing.Optional[str] = pydantic_v1.Field(alias="uploadUrl", default=None) + asset_url: typing.Optional[str] = pydantic_v1.Field(alias="assetUrl", default=None) + """ + S3 link to the asset + """ + + hosted_url: typing.Optional[str] = pydantic_v1.Field(alias="hostedUrl", default=None) + """ + Represents the link to the asset + """ + + original_file_name: typing.Optional[str] = pydantic_v1.Field(alias="originalFileName", default=None) + """ + Original file name when uploaded. If not specified at time of upload, it may be extracted from the raw file name + """ + + created_on: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="createdOn", default=None) + """ + Date the asset metadata was created + """ + + last_updated: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="lastUpdated", default=None) + """ + Date the asset metadata was last updated + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/asset_upload_upload_details.py b/src/webflow/types/asset_upload_upload_details.py index 244ad84..40735bb 100644 --- a/src/webflow/types/asset_upload_upload_details.py +++ b/src/webflow/types/asset_upload_upload_details.py @@ -4,45 +4,42 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class AssetUploadUploadDetails(pydantic.BaseModel): +class AssetUploadUploadDetails(pydantic_v1.BaseModel): """ Metadata for uploading the asset binary """ acl: typing.Optional[str] = None bucket: typing.Optional[str] = None + x_amz_algorithm: typing.Optional[str] = pydantic_v1.Field(alias="X-Amz-Algorithm", default=None) + x_amz_credential: typing.Optional[str] = pydantic_v1.Field(alias="X-Amz-Credential", default=None) + x_amz_date: typing.Optional[str] = pydantic_v1.Field(alias="X-Amz-Date", default=None) key: typing.Optional[str] = None - policy: typing.Optional[str] = pydantic.Field(alias="Policy", default=None) - x_amz_algorithm: typing.Optional[str] = pydantic.Field(alias="X-Amz-Algorithm", default=None) - x_amz_credential: typing.Optional[str] = pydantic.Field(alias="X-Amz-Credential", default=None) - x_amz_date: typing.Optional[str] = pydantic.Field(alias="X-Amz-Date", default=None) - x_amz_security_token: typing.Optional[str] = pydantic.Field( - alias="X-Amz-Security-Token", - default=None, - description="(optional) Temporary security token obtained when authenticated through AWS STS", - ) - x_amz_signature: typing.Optional[str] = pydantic.Field(alias="X-Amz-Signature", default=None) + policy: typing.Optional[str] = pydantic_v1.Field(alias="Policy", default=None) + x_amz_signature: typing.Optional[str] = pydantic_v1.Field(alias="X-Amz-Signature", default=None) success_action_status: typing.Optional[str] = None - content_type: typing.Optional[str] = pydantic.Field(alias="content-type", default=None) - cache_control: typing.Optional[str] = pydantic.Field(alias="Cache-Control", default=None) + content_type: typing.Optional[str] = pydantic_v1.Field(alias="content-type", default=None) + cache_control: typing.Optional[str] = pydantic_v1.Field(alias="Cache-Control", default=None) def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/asset_variant.py b/src/webflow/types/asset_variant.py index 00af16a..ca4e205 100644 --- a/src/webflow/types/asset_variant.py +++ b/src/webflow/types/asset_variant.py @@ -4,35 +4,66 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore +class AssetVariant(pydantic_v1.BaseModel): + hosted_url: typing.Optional[str] = pydantic_v1.Field(alias="hostedUrl", default=None) + """ + URL of where the asset variant is hosted + """ -class AssetVariant(pydantic.BaseModel): - hosted_url: typing.Optional[str] = pydantic.Field(alias="hostedUrl", default=None) - original_file_name: typing.Optional[str] = pydantic.Field(alias="originalFileName", default=None) - display_name: typing.Optional[str] = pydantic.Field(alias="displayName", default=None) - format: typing.Optional[str] = None - width: typing.Optional[int] = pydantic.Field(default=None, description="Width in pixels") - height: typing.Optional[int] = pydantic.Field(default=None, description="Height in pixels") - quality: typing.Optional[int] = pydantic.Field( - default=None, description="Value between 0 and 100 representing the image quality" - ) - error: typing.Optional[str] = pydantic.Field(default=None, description="Any associated validation errors") + original_file_name: typing.Optional[str] = pydantic_v1.Field(alias="originalFileName", default=None) + """ + Original file name of the variant + """ + + display_name: typing.Optional[str] = pydantic_v1.Field(alias="displayName", default=None) + """ + Display name of the variant + """ + + format: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + format of the variant + """ + + width: typing.Optional[int] = pydantic_v1.Field(default=None) + """ + Width in pixels + """ + + height: typing.Optional[int] = pydantic_v1.Field(default=None) + """ + Height in pixels + """ + + quality: typing.Optional[int] = pydantic_v1.Field(default=None) + """ + Value between 0 and 100 representing the image quality + """ + + error: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + Any associated validation errors + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/assets.py b/src/webflow/types/assets.py index 3b1ee70..1d4dbfc 100644 --- a/src/webflow/types/assets.py +++ b/src/webflow/types/assets.py @@ -4,15 +4,11 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .asset import Asset -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class Assets(pydantic.BaseModel): +class Assets(pydantic_v1.BaseModel): """ A list of assets """ @@ -24,10 +20,15 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/authorization.py b/src/webflow/types/authorization.py index c896ac6..ecb2ed7 100644 --- a/src/webflow/types/authorization.py +++ b/src/webflow/types/authorization.py @@ -4,19 +4,17 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .application import Application from .authorization_authorization import AuthorizationAuthorization -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore +class Authorization(pydantic_v1.BaseModel): + authorization: typing.Optional[AuthorizationAuthorization] = pydantic_v1.Field(default=None) + """ + The Authorization object + """ -class Authorization(pydantic.BaseModel): - authorization: typing.Optional[AuthorizationAuthorization] = pydantic.Field( - default=None, description="The Authorization object" - ) application: typing.Optional[Application] = None def json(self, **kwargs: typing.Any) -> str: @@ -24,10 +22,15 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/authorization_authorization.py b/src/webflow/types/authorization_authorization.py index cb2780e..9410526 100644 --- a/src/webflow/types/authorization_authorization.py +++ b/src/webflow/types/authorization_authorization.py @@ -4,36 +4,46 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .authorization_authorization_authorized_to import AuthorizationAuthorizationAuthorizedTo -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class AuthorizationAuthorization(pydantic.BaseModel): +class AuthorizationAuthorization(pydantic_v1.BaseModel): """ The Authorization object """ - id: typing.Optional[str] = pydantic.Field(default=None, description="The unique id of the Authorization instance") - created_on: typing.Optional[dt.datetime] = pydantic.Field( - alias="createdOn", default=None, description="The date the Authorization was created" - ) - last_used: typing.Optional[dt.datetime] = pydantic.Field( - alias="lastUsed", default=None, description="The date the Authorization was last used" - ) - grant_type: typing.Optional[str] = pydantic.Field( - alias="grantType", default=None, description="The grant type of the Authorization" - ) - rate_limit: typing.Optional[int] = pydantic.Field( - alias="rateLimit", default=None, description="The default rate limit for the Authorization (requests/min)" - ) - scope: typing.Optional[str] = pydantic.Field( - default=None, description="Comma separted list of OAuth scopes corresponding to the Authorization" - ) - authorized_to: typing.Optional[AuthorizationAuthorizationAuthorizedTo] = pydantic.Field( + id: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + The unique id of the Authorization instance + """ + + created_on: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="createdOn", default=None) + """ + The date the Authorization was created + """ + + last_used: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="lastUsed", default=None) + """ + The date the Authorization was last used + """ + + grant_type: typing.Optional[str] = pydantic_v1.Field(alias="grantType", default=None) + """ + The grant type of the Authorization + """ + + rate_limit: typing.Optional[int] = pydantic_v1.Field(alias="rateLimit", default=None) + """ + The default rate limit for the Authorization (requests/min) + """ + + scope: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + Comma separted list of OAuth scopes corresponding to the Authorization + """ + + authorized_to: typing.Optional[AuthorizationAuthorizationAuthorizedTo] = pydantic_v1.Field( alias="authorizedTo", default=None ) @@ -42,11 +52,17 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/authorization_authorization_authorized_to.py b/src/webflow/types/authorization_authorization_authorized_to.py index e80f490..cb59ffc 100644 --- a/src/webflow/types/authorization_authorization_authorized_to.py +++ b/src/webflow/types/authorization_authorization_authorized_to.py @@ -4,34 +4,41 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore +class AuthorizationAuthorizationAuthorizedTo(pydantic_v1.BaseModel): + site_ids: typing.Optional[typing.List[typing.Any]] = pydantic_v1.Field(alias="siteIds", default=None) + """ + Array of Sites this app is authorized to + """ -class AuthorizationAuthorizationAuthorizedTo(pydantic.BaseModel): - site_ids: typing.Optional[typing.List[typing.Any]] = pydantic.Field( - alias="siteIds", default=None, description="Array of Sites this app is authorized to" - ) - workspace_ids: typing.Optional[typing.List[typing.Any]] = pydantic.Field( - alias="workspaceIds", default=None, description="Array of Workspaces this app is authorized to" - ) - user_ids: typing.Optional[typing.List[typing.Any]] = pydantic.Field( - alias="userIds", default=None, description="Array of Users this app is authorized to" - ) + workspace_ids: typing.Optional[typing.List[typing.Any]] = pydantic_v1.Field(alias="workspaceIds", default=None) + """ + Array of Workspaces this app is authorized to + """ + + user_ids: typing.Optional[typing.List[typing.Any]] = pydantic_v1.Field(alias="userIds", default=None) + """ + Array of Users this app is authorized to + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/authorized_user.py b/src/webflow/types/authorized_user.py index 8f754d3..80c4931 100644 --- a/src/webflow/types/authorized_user.py +++ b/src/webflow/types/authorized_user.py @@ -4,31 +4,46 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore +class AuthorizedUser(pydantic_v1.BaseModel): + id: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + The unique id of the user + """ -class AuthorizedUser(pydantic.BaseModel): - id: typing.Optional[str] = pydantic.Field(default=None, description="The unique id of the user") - email: typing.Optional[str] = pydantic.Field(default=None, description="The user's email address") - first_name: typing.Optional[str] = pydantic.Field( - alias="firstName", default=None, description="The user's first name" - ) - last_name: typing.Optional[str] = pydantic.Field(alias="lastName", default=None, description="The user's last name") + email: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + The user's email address + """ + + first_name: typing.Optional[str] = pydantic_v1.Field(alias="firstName", default=None) + """ + The user's first name + """ + + last_name: typing.Optional[str] = pydantic_v1.Field(alias="lastName", default=None) + """ + The user's last name + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/bad_request_error_body.py b/src/webflow/types/bad_request_error_body.py new file mode 100644 index 0000000..6403cc4 --- /dev/null +++ b/src/webflow/types/bad_request_error_body.py @@ -0,0 +1,8 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from .invalid_domain import InvalidDomain +from .no_domains import NoDomains + +BadRequestErrorBody = typing.Union[InvalidDomain, NoDomains] diff --git a/src/webflow/types/collection.py b/src/webflow/types/collection.py index 6887a61..4be489d 100644 --- a/src/webflow/types/collection.py +++ b/src/webflow/types/collection.py @@ -4,46 +4,66 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from .field import Field -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class Collection(pydantic.BaseModel): +class Collection(pydantic_v1.BaseModel): """ A collection object """ - id: str = pydantic.Field(description="Unique identifier for a Collection") - display_name: typing.Optional[str] = pydantic.Field( - alias="displayName", default=None, description="Name given to the Collection" - ) - singular_name: typing.Optional[str] = pydantic.Field( - alias="singularName", - default=None, - description="The name of one Item in Collection (e.g. ”Blog Post” if the Collection is called “Blog Posts”)", - ) - slug: typing.Optional[str] = pydantic.Field(default=None, description="Slug of Collection in Site URL structure") - created_on: typing.Optional[dt.datetime] = pydantic.Field( - alias="createdOn", default=None, description="The date the collection was created" - ) - last_updated: typing.Optional[dt.datetime] = pydantic.Field( - alias="lastUpdated", default=None, description="The date the collection was last updated" - ) - fields: typing.Dict[str, typing.Any] = pydantic.Field(description="The list of fields in the Collection") + id: str = pydantic_v1.Field() + """ + Unique identifier for a Collection + """ + + display_name: typing.Optional[str] = pydantic_v1.Field(alias="displayName", default=None) + """ + Name given to the Collection + """ + + singular_name: typing.Optional[str] = pydantic_v1.Field(alias="singularName", default=None) + """ + The name of one Item in Collection (e.g. ”Blog Post” if the Collection is called “Blog Posts”) + """ + + slug: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + Slug of Collection in Site URL structure + """ + + created_on: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="createdOn", default=None) + """ + The date the collection was created + """ + + last_updated: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="lastUpdated", default=None) + """ + The date the collection was last updated + """ + + fields: typing.List[Field] = pydantic_v1.Field() + """ + The list of fields in the Collection + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/collection_item.py b/src/webflow/types/collection_item.py index 82a0629..d7e2e1d 100644 --- a/src/webflow/types/collection_item.py +++ b/src/webflow/types/collection_item.py @@ -4,50 +4,68 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .collection_item_field_data import CollectionItemFieldData -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class CollectionItem(pydantic.BaseModel): +class CollectionItem(pydantic_v1.BaseModel): """ The fields that define the schema for a given Item are based on the Collection that Item belongs to. Beyond the user defined fields, there are a handful of additional fields that are automatically created for all items """ - id: str = pydantic.Field(description="Unique identifier for the Item") - cms_locale_id: typing.Optional[str] = pydantic.Field( - alias="cmsLocaleId", default=None, description="Identifier for the locale of the CMS item" - ) - last_published: typing.Optional[str] = pydantic.Field( - alias="lastPublished", default=None, description="The date the item was last published" - ) - last_updated: typing.Optional[str] = pydantic.Field( - alias="lastUpdated", default=None, description="The date the item was last updated" - ) - created_on: typing.Optional[str] = pydantic.Field( - alias="createdOn", default=None, description="The date the item was created" - ) - is_archived: typing.Optional[bool] = pydantic.Field( - alias="isArchived", default=None, description="Boolean determining if the Item is set to archived" - ) - is_draft: typing.Optional[bool] = pydantic.Field( - alias="isDraft", default=None, description="Boolean determining if the Item is set to draft" - ) - field_data: typing.Optional[CollectionItemFieldData] = pydantic.Field(alias="fieldData", default=None) + id: str = pydantic_v1.Field() + """ + Unique identifier for the Item + """ + + cms_locale_id: typing.Optional[str] = pydantic_v1.Field(alias="cmsLocaleId", default=None) + """ + Identifier for the locale of the CMS item + """ + + last_published: typing.Optional[str] = pydantic_v1.Field(alias="lastPublished", default=None) + """ + The date the item was last published + """ + + last_updated: typing.Optional[str] = pydantic_v1.Field(alias="lastUpdated", default=None) + """ + The date the item was last updated + """ + + created_on: typing.Optional[str] = pydantic_v1.Field(alias="createdOn", default=None) + """ + The date the item was created + """ + + is_archived: typing.Optional[bool] = pydantic_v1.Field(alias="isArchived", default=None) + """ + Boolean determining if the Item is set to archived + """ + + is_draft: typing.Optional[bool] = pydantic_v1.Field(alias="isDraft", default=None) + """ + Boolean determining if the Item is set to draft + """ + + field_data: typing.Optional[CollectionItemFieldData] = pydantic_v1.Field(alias="fieldData", default=None) def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/collection_item_field_data.py b/src/webflow/types/collection_item_field_data.py index ba2c2fc..19b8588 100644 --- a/src/webflow/types/collection_item_field_data.py +++ b/src/webflow/types/collection_item_field_data.py @@ -4,29 +4,34 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore +class CollectionItemFieldData(pydantic_v1.BaseModel): + name: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + Name of the Item + """ -class CollectionItemFieldData(pydantic.BaseModel): - name: typing.Optional[str] = pydantic.Field(default=None, description="Name of the Item") - slug: typing.Optional[str] = pydantic.Field( - default=None, - description="URL structure of the Item in your site. Note: Updates to an item slug will break all links referencing the old slug.", - ) + slug: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + URL structure of the Item in your site. Note: Updates to an item slug will break all links referencing the old slug. + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/collection_item_list.py b/src/webflow/types/collection_item_list.py index 11f519c..2414299 100644 --- a/src/webflow/types/collection_item_list.py +++ b/src/webflow/types/collection_item_list.py @@ -4,23 +4,21 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .collection_item import CollectionItem from .collection_item_list_pagination import CollectionItemListPagination -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class CollectionItemList(pydantic.BaseModel): +class CollectionItemList(pydantic_v1.BaseModel): """ Results from collection items list """ - items: typing.Optional[typing.List[CollectionItem]] = pydantic.Field( - default=None, description="List of Items within the collection" - ) + items: typing.Optional[typing.List[CollectionItem]] = pydantic_v1.Field(default=None) + """ + List of Items within the collection + """ + pagination: typing.Optional[CollectionItemListPagination] = None def json(self, **kwargs: typing.Any) -> str: @@ -28,10 +26,15 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/collection_item_list_pagination.py b/src/webflow/types/collection_item_list_pagination.py index ffb4c77..3a7380b 100644 --- a/src/webflow/types/collection_item_list_pagination.py +++ b/src/webflow/types/collection_item_list_pagination.py @@ -4,27 +4,39 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore +class CollectionItemListPagination(pydantic_v1.BaseModel): + limit: typing.Optional[float] = pydantic_v1.Field(default=None) + """ + The limit specified in the request + """ -class CollectionItemListPagination(pydantic.BaseModel): - limit: typing.Optional[float] = pydantic.Field(default=None, description="The limit specified in the request") - offset: typing.Optional[float] = pydantic.Field(default=None, description="The offset specified for pagination") - total: typing.Optional[float] = pydantic.Field(default=None, description="Total number of items in the collection") + offset: typing.Optional[float] = pydantic_v1.Field(default=None) + """ + The offset specified for pagination + """ + + total: typing.Optional[float] = pydantic_v1.Field(default=None) + """ + Total number of items in the collection + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/collection_list.py b/src/webflow/types/collection_list.py index 683b028..4e5a51c 100644 --- a/src/webflow/types/collection_list.py +++ b/src/webflow/types/collection_list.py @@ -4,28 +4,30 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .collection_list_array_item import CollectionListArrayItem -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class CollectionList(pydantic.BaseModel): - collections: typing.Optional[typing.List[CollectionListArrayItem]] = pydantic.Field( - default=None, description="An array of Collections" - ) +class CollectionList(pydantic_v1.BaseModel): + collections: typing.Optional[typing.List[CollectionListArrayItem]] = pydantic_v1.Field(default=None) + """ + An array of Collections + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/collection_list_array_item.py b/src/webflow/types/collection_list_array_item.py index 2669222..734f947 100644 --- a/src/webflow/types/collection_list_array_item.py +++ b/src/webflow/types/collection_list_array_item.py @@ -4,45 +4,60 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class CollectionListArrayItem(pydantic.BaseModel): +class CollectionListArrayItem(pydantic_v1.BaseModel): """ A collection object """ - id: str = pydantic.Field(description="Unique identifier for a Collection") - display_name: typing.Optional[str] = pydantic.Field( - alias="displayName", default=None, description="Name given to the Collection" - ) - singular_name: typing.Optional[str] = pydantic.Field( - alias="singularName", - default=None, - description="The name of one Item in Collection (e.g. ”Blog Post” if the Collection is called “Blog Posts”)", - ) - slug: typing.Optional[str] = pydantic.Field(default=None, description="Slug of Collection in Site URL structure") - created_on: typing.Optional[dt.datetime] = pydantic.Field( - alias="createdOn", default=None, description="The date the collection was created" - ) - last_updated: typing.Optional[dt.datetime] = pydantic.Field( - alias="lastUpdated", default=None, description="The date the collection was last updated" - ) + id: str = pydantic_v1.Field() + """ + Unique identifier for a Collection + """ + + display_name: typing.Optional[str] = pydantic_v1.Field(alias="displayName", default=None) + """ + Name given to the Collection + """ + + singular_name: typing.Optional[str] = pydantic_v1.Field(alias="singularName", default=None) + """ + The name of one Item in Collection (e.g. ”Blog Post” if the Collection is called “Blog Posts”) + """ + + slug: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + Slug of Collection in Site URL structure + """ + + created_on: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="createdOn", default=None) + """ + The date the collection was created + """ + + last_updated: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="lastUpdated", default=None) + """ + The date the collection was last updated + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/conflict_error_body.py b/src/webflow/types/conflict_error_body.py new file mode 100644 index 0000000..7f34146 --- /dev/null +++ b/src/webflow/types/conflict_error_body.py @@ -0,0 +1,8 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from .duplicate_user_email import DuplicateUserEmail +from .user_limit_reached import UserLimitReached + +ConflictErrorBody = typing.Union[DuplicateUserEmail, UserLimitReached] diff --git a/src/webflow/types/custom_code_block.py b/src/webflow/types/custom_code_block.py index 20cc019..4252be7 100644 --- a/src/webflow/types/custom_code_block.py +++ b/src/webflow/types/custom_code_block.py @@ -4,47 +4,58 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .custom_code_block_type import CustomCodeBlockType from .scripts import Scripts -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class CustomCodeBlock(pydantic.BaseModel): +class CustomCodeBlock(pydantic_v1.BaseModel): """ A specific instance of Custom Code applied to a Site or Page """ - site_id: typing.Optional[str] = pydantic.Field( - alias="siteId", default=None, description="The Site id where the custom code was applied" - ) - page_id: typing.Optional[str] = pydantic.Field( - alias="pageId", default=None, description="The Page id (if applied at Page-level)" - ) - type: typing.Optional[CustomCodeBlockType] = pydantic.Field( - default=None, description="Whether the Custom Code script is applied at the Site-level or Page-level" - ) + site_id: typing.Optional[str] = pydantic_v1.Field(alias="siteId", default=None) + """ + The Site id where the custom code was applied + """ + + page_id: typing.Optional[str] = pydantic_v1.Field(alias="pageId", default=None) + """ + The Page id (if applied at Page-level) + """ + + type: typing.Optional[CustomCodeBlockType] = pydantic_v1.Field(default=None) + """ + Whether the Custom Code script is applied at the Site-level or Page-level + """ + scripts: typing.Optional[Scripts] = None - created_on: typing.Optional[dt.datetime] = pydantic.Field( - alias="createdOn", default=None, description="The date the Block was created" - ) - last_updated: typing.Optional[dt.datetime] = pydantic.Field( - alias="lastUpdated", default=None, description="The date the Block was most recently updated" - ) + created_on: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="createdOn", default=None) + """ + The date the Block was created + """ + + last_updated: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="lastUpdated", default=None) + """ + The date the Block was most recently updated + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/custom_code_hosted_response.py b/src/webflow/types/custom_code_hosted_response.py new file mode 100644 index 0000000..61011c3 --- /dev/null +++ b/src/webflow/types/custom_code_hosted_response.py @@ -0,0 +1,73 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 + + +class CustomCodeHostedResponse(pydantic_v1.BaseModel): + """ + Registered custom code for application + """ + + id: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + Human readable id, derived from the user-specified display name + """ + + can_copy: typing.Optional[bool] = pydantic_v1.Field(alias="canCopy", default=None) + """ + Define whether the script can be copied on site duplication and transfer + """ + + display_name: typing.Optional[str] = pydantic_v1.Field(alias="displayName", default=None) + """ + User-facing name for the script. Must be between 1 and 50 alphanumeric characters + """ + + hosted_location: typing.Optional[str] = pydantic_v1.Field(alias="hostedLocation", default=None) + """ + URI for an externally hosted script location + """ + + integrity_hash: typing.Optional[str] = pydantic_v1.Field(alias="integrityHash", default=None) + """ + Sub-Resource Integrity Hash. Only required for externally hosted scripts (passed via hostedLocation) + """ + + created_on: typing.Optional[str] = pydantic_v1.Field(alias="createdOn", default=None) + """ + Timestamp when the script version was created + """ + + last_updated: typing.Optional[str] = pydantic_v1.Field(alias="lastUpdated", default=None) + """ + Timestamp when the script version was last updated + """ + + version: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + A Semantic Version (SemVer) string, denoting the version of the script + """ + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) + + class Config: + frozen = True + smart_union = True + allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/custom_code_inline_response.py b/src/webflow/types/custom_code_inline_response.py new file mode 100644 index 0000000..a0301c1 --- /dev/null +++ b/src/webflow/types/custom_code_inline_response.py @@ -0,0 +1,73 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 + + +class CustomCodeInlineResponse(pydantic_v1.BaseModel): + """ + Registered custom code for application + """ + + id: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + Human readable id, derived from the user-specified display name + """ + + can_copy: typing.Optional[bool] = pydantic_v1.Field(alias="canCopy", default=None) + """ + Define whether the script can be copied on site duplication and transfer + """ + + display_name: typing.Optional[str] = pydantic_v1.Field(alias="displayName", default=None) + """ + User-facing name for the script. Must be between 1 and 50 alphanumeric characters + """ + + hosted_location: typing.Optional[str] = pydantic_v1.Field(alias="hostedLocation", default=None) + """ + URI for an externally hosted script location + """ + + integrity_hash: typing.Optional[str] = pydantic_v1.Field(alias="integrityHash", default=None) + """ + Sub-Resource Integrity Hash. Only required for externally hosted scripts (passed via hostedLocation) + """ + + created_on: typing.Optional[str] = pydantic_v1.Field(alias="createdOn", default=None) + """ + Timestamp when the script version was created + """ + + last_updated: typing.Optional[str] = pydantic_v1.Field(alias="lastUpdated", default=None) + """ + Timestamp when the script version was last updated + """ + + version: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + A Semantic Version (SemVer) string, denoting the version of the script + """ + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) + + class Config: + frozen = True + smart_union = True + allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/custom_code_response.py b/src/webflow/types/custom_code_response.py deleted file mode 100644 index 2765ca9..0000000 --- a/src/webflow/types/custom_code_response.py +++ /dev/null @@ -1,60 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import datetime as dt -import typing - -from ..core.datetime_utils import serialize_datetime - -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - - -class CustomCodeResponse(pydantic.BaseModel): - """ - Registered custom code for application - """ - - id: typing.Optional[str] = pydantic.Field( - default=None, description="Human readable id, derived from the user-specified display name" - ) - created_on: typing.Optional[str] = pydantic.Field( - alias="createdOn", default=None, description="Timestamp when the script version was created" - ) - last_updated: typing.Optional[str] = pydantic.Field( - alias="lastUpdated", default=None, description="Timestamp when the script version was last updated" - ) - hosted_location: typing.Optional[str] = pydantic.Field( - alias="hostedLocation", default=None, description="URI for an externally hosted script location" - ) - integrity_hash: typing.Optional[str] = pydantic.Field( - alias="integrityHash", - default=None, - description="Sub-Resource Integrity Hash. Only required for externally hosted scripts (passed via hostedLocation)", - ) - can_copy: typing.Optional[bool] = pydantic.Field( - alias="canCopy", - default=None, - description="Define whether the script can be copied on site duplication and transfer", - ) - version: typing.Optional[str] = pydantic.Field( - default=None, description="A Semantic Version (SemVer) string, denoting the version of the script" - ) - display_name: typing.Optional[str] = pydantic.Field( - alias="displayName", default=None, description="User-facing name for the script" - ) - - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) - - class Config: - frozen = True - smart_union = True - allow_population_by_field_name = True - json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/dom.py b/src/webflow/types/dom.py index c6e1d9a..d922f40 100644 --- a/src/webflow/types/dom.py +++ b/src/webflow/types/dom.py @@ -4,21 +4,21 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .node import Node from .pagination import Pagination -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class Dom(pydantic.BaseModel): +class Dom(pydantic_v1.BaseModel): """ The DOM (Document Object Model) schema represents the content structure of a web page. It captures various content nodes, such as text and images, along with their associated attributes. Each node has a unique identifier and can be of different types like text or image. The schema also provides pagination details for scenarios where the content nodes are too many to be fetched in a single request. """ - page_id: typing.Optional[str] = pydantic.Field(alias="pageId", default=None, description="Page ID") + page_id: typing.Optional[str] = pydantic_v1.Field(alias="pageId", default=None) + """ + Page ID + """ + nodes: typing.Optional[typing.List[Node]] = None pagination: typing.Optional[Pagination] = None @@ -27,11 +27,17 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/domain.py b/src/webflow/types/domain.py index 1b69fa5..fdd9a92 100644 --- a/src/webflow/types/domain.py +++ b/src/webflow/types/domain.py @@ -4,26 +4,34 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore +class Domain(pydantic_v1.BaseModel): + id: str = pydantic_v1.Field() + """ + Unique identifier for the Domain + """ -class Domain(pydantic.BaseModel): - id: str = pydantic.Field(description="Unique identifier for the Domain") - url: typing.Optional[str] = pydantic.Field(default=None, description="The registered Domain name") + url: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + The registered Domain name + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/domains.py b/src/webflow/types/domains.py index e9bde11..dcfd0ef 100644 --- a/src/webflow/types/domains.py +++ b/src/webflow/types/domains.py @@ -4,27 +4,29 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .domain import Domain -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class Domains(pydantic.BaseModel): - custom_domains: typing.Optional[typing.List[Domain]] = pydantic.Field(alias="customDomains", default=None) +class Domains(pydantic_v1.BaseModel): + custom_domains: typing.Optional[typing.List[Domain]] = pydantic_v1.Field(alias="customDomains", default=None) def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/duplicate_user_email.py b/src/webflow/types/duplicate_user_email.py index cfc148a..31cf125 100644 --- a/src/webflow/types/duplicate_user_email.py +++ b/src/webflow/types/duplicate_user_email.py @@ -1,37 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing +from .error import Error -from ..core.datetime_utils import serialize_datetime -from .error_details_item import ErrorDetailsItem - -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - - -class DuplicateUserEmail(pydantic.BaseModel): - code: typing.Optional[str] = pydantic.Field(default=None, description="Error code") - message: typing.Optional[str] = pydantic.Field(default=None, description="Error message") - external_reference: typing.Optional[str] = pydantic.Field( - alias="externalReference", default=None, description="Link to more information" - ) - details: typing.Optional[typing.List[ErrorDetailsItem]] = pydantic.Field( - default=None, description="Array of errors" - ) - - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) - - class Config: - frozen = True - smart_union = True - allow_population_by_field_name = True - json_encoders = {dt.datetime: serialize_datetime} +DuplicateUserEmail = Error diff --git a/src/webflow/types/ecommerce_settings.py b/src/webflow/types/ecommerce_settings.py index 6b6b110..6f58259 100644 --- a/src/webflow/types/ecommerce_settings.py +++ b/src/webflow/types/ecommerce_settings.py @@ -4,38 +4,45 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class EcommerceSettings(pydantic.BaseModel): +class EcommerceSettings(pydantic_v1.BaseModel): """ Ecommerce settings for a Webflow Site """ - site_id: typing.Optional[str] = pydantic.Field( - alias="siteId", default=None, description="The identifier of the Site" - ) - created_on: typing.Optional[dt.datetime] = pydantic.Field( - alias="createdOn", default=None, description="Date that the Site was created on" - ) - default_currency: typing.Optional[str] = pydantic.Field( - alias="defaultCurrency", default=None, description="The three-letter ISO currency code for the Site" - ) + site_id: typing.Optional[str] = pydantic_v1.Field(alias="siteId", default=None) + """ + The identifier of the Site + """ + + created_on: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="createdOn", default=None) + """ + Date that the Site was created on + """ + + default_currency: typing.Optional[str] = pydantic_v1.Field(alias="defaultCurrency", default=None) + """ + The three-letter ISO currency code for the Site + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/error.py b/src/webflow/types/error.py index c8574ab..ead5b4d 100644 --- a/src/webflow/types/error.py +++ b/src/webflow/types/error.py @@ -4,34 +4,47 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .error_details_item import ErrorDetailsItem -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore +class Error(pydantic_v1.BaseModel): + code: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + Error code + """ -class Error(pydantic.BaseModel): - code: typing.Optional[str] = pydantic.Field(default=None, description="Error code") - message: typing.Optional[str] = pydantic.Field(default=None, description="Error message") - external_reference: typing.Optional[str] = pydantic.Field( - alias="externalReference", default=None, description="Link to more information" - ) - details: typing.Optional[typing.List[ErrorDetailsItem]] = pydantic.Field( - default=None, description="Array of errors" - ) + message: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + Error message + """ + + external_reference: typing.Optional[str] = pydantic_v1.Field(alias="externalReference", default=None) + """ + Link to more information + """ + + details: typing.Optional[typing.List[ErrorDetailsItem]] = pydantic_v1.Field(default=None) + """ + Array of errors + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/field.py b/src/webflow/types/field.py index a2f8117..d5823cd 100644 --- a/src/webflow/types/field.py +++ b/src/webflow/types/field.py @@ -4,46 +4,66 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .field_type import FieldType -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class Field(pydantic.BaseModel): +class Field(pydantic_v1.BaseModel): """ The details of a field in a collection """ - id: str = pydantic.Field(description="Unique identifier for a Field") - is_required: bool = pydantic.Field( - alias="isRequired", description="define whether a field is required in a collection" - ) - is_editable: typing.Optional[bool] = pydantic.Field( - alias="isEditable", default=None, description="Define whether the field is editable" - ) - type: FieldType = pydantic.Field(description="Choose these appropriate field type for your collection data") - slug: typing.Optional[str] = pydantic.Field( - default=None, - description='Slug of Field in Site URL structure. Slugs should be all lowercase with no spaces. Any spaces will be converted to "-."', - ) - display_name: str = pydantic.Field(alias="displayName", description="The name of a field") - help_text: typing.Optional[str] = pydantic.Field( - alias="helpText", default=None, description="Additional text to help anyone filling out this field" - ) + id: str = pydantic_v1.Field() + """ + Unique identifier for a Field + """ + + is_required: bool = pydantic_v1.Field(alias="isRequired") + """ + define whether a field is required in a collection + """ + + is_editable: typing.Optional[bool] = pydantic_v1.Field(alias="isEditable", default=None) + """ + Define whether the field is editable + """ + + type: FieldType = pydantic_v1.Field() + """ + Choose these appropriate field type for your collection data + """ + + slug: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + Slug of Field in Site URL structure. Slugs should be all lowercase with no spaces. Any spaces will be converted to "-." + """ + + display_name: str = pydantic_v1.Field(alias="displayName") + """ + The name of a field + """ + + help_text: typing.Optional[str] = pydantic_v1.Field(alias="helpText", default=None) + """ + Additional text to help anyone filling out this field + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/field_type.py b/src/webflow/types/field_type.py index d40aa66..2b60793 100644 --- a/src/webflow/types/field_type.py +++ b/src/webflow/types/field_type.py @@ -21,7 +21,7 @@ class FieldType(str, enum.Enum): PHONE = "Phone" NUMBER = "Number" DATE_TIME = "DateTime" - BOOLEAN = "Boolean" + SWITCH = "Switch" COLOR = "Color" EXT_FILE_REF = "ExtFileRef" @@ -37,7 +37,7 @@ def visit( phone: typing.Callable[[], T_Result], number: typing.Callable[[], T_Result], date_time: typing.Callable[[], T_Result], - boolean: typing.Callable[[], T_Result], + switch: typing.Callable[[], T_Result], color: typing.Callable[[], T_Result], ext_file_ref: typing.Callable[[], T_Result], ) -> T_Result: @@ -61,8 +61,8 @@ def visit( return number() if self is FieldType.DATE_TIME: return date_time() - if self is FieldType.BOOLEAN: - return boolean() + if self is FieldType.SWITCH: + return switch() if self is FieldType.COLOR: return color() if self is FieldType.EXT_FILE_REF: diff --git a/src/webflow/types/forbidden_error_body.py b/src/webflow/types/forbidden_error_body.py new file mode 100644 index 0000000..7f36dc7 --- /dev/null +++ b/src/webflow/types/forbidden_error_body.py @@ -0,0 +1,35 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 + + +class ForbiddenErrorBody(pydantic_v1.BaseModel): + status: typing.Optional[int] = None + message: typing.Optional[str] = None + public_error_code: typing.Optional[str] = pydantic_v1.Field(alias="publicErrorCode", default=None) + external_reference: typing.Optional[str] = pydantic_v1.Field(alias="externalReference", default=None) + details: typing.Optional[typing.List[str]] = None + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) + + class Config: + frozen = True + smart_union = True + allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/form.py b/src/webflow/types/form.py index 82a2f69..ae2a5e7 100644 --- a/src/webflow/types/form.py +++ b/src/webflow/types/form.py @@ -4,54 +4,87 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .form_field import FormField from .form_response_settings import FormResponseSettings -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - - -class Form(pydantic.BaseModel): - id: typing.Optional[str] = pydantic.Field(default=None, description="The unique id for the Form") - display_name: typing.Optional[str] = pydantic.Field( - alias="displayName", default=None, description="The Form name displayed on the site" - ) - site_id: typing.Optional[str] = pydantic.Field( - alias="siteId", default=None, description="The unique id of the Site the Form belongs to" - ) - site_domain_id: typing.Optional[str] = pydantic.Field( - alias="siteDomainId", default=None, description="The unique id corresponding to the site's Domain name" - ) - page_id: typing.Optional[str] = pydantic.Field( - alias="pageId", default=None, description="The unique id for the Page on which the Form is placed" - ) - page_name: typing.Optional[str] = pydantic.Field( - alias="pageName", default=None, description="The user-visible name of the Page where the Form is placed" - ) - workspace_id: typing.Optional[str] = pydantic.Field( - alias="workspaceId", default=None, description="The unique id of the Workspace the Site belongs to" - ) - created_on: typing.Optional[dt.datetime] = pydantic.Field( - alias="createdOn", default=None, description="Date that the Form was created on" - ) - last_updated: typing.Optional[dt.datetime] = pydantic.Field( - alias="lastUpdated", default=None, description="Date that the Form was last updated on" - ) - fields: typing.Optional[typing.List[FormField]] = None - response_settings: typing.Optional[FormResponseSettings] = pydantic.Field(alias="responseSettings", default=None) + +class Form(pydantic_v1.BaseModel): + """ + A Webflow form + """ + + display_name: typing.Optional[str] = pydantic_v1.Field(alias="displayName", default=None) + """ + The Form name displayed on the site + """ + + created_on: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="createdOn", default=None) + """ + Date that the Form was created on + """ + + last_updated: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="lastUpdated", default=None) + """ + Date that the Form was last updated on + """ + + fields: typing.Optional[typing.List[FormField]] = pydantic_v1.Field(default=None) + """ + A list of form fields + """ + + response_settings: typing.Optional[FormResponseSettings] = pydantic_v1.Field(alias="responseSettings", default=None) + """ + Settings for form responses + """ + + id: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + The unique id for the Form + """ + + site_id: typing.Optional[str] = pydantic_v1.Field(alias="siteId", default=None) + """ + The unique id of the Site the Form belongs to + """ + + site_domain_id: typing.Optional[str] = pydantic_v1.Field(alias="siteDomainId", default=None) + """ + The unique id corresponding to the site's Domain name + """ + + page_id: typing.Optional[str] = pydantic_v1.Field(alias="pageId", default=None) + """ + The unique id for the Page on which the Form is placed + """ + + page_name: typing.Optional[str] = pydantic_v1.Field(alias="pageName", default=None) + """ + The user-visible name of the Page where the Form is placed + """ + + workspace_id: typing.Optional[str] = pydantic_v1.Field(alias="workspaceId", default=None) + """ + The unique id of the Workspace the Site belongs to + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/form_field_value.py b/src/webflow/types/form_field_value.py index dafb390..0a737ca 100644 --- a/src/webflow/types/form_field_value.py +++ b/src/webflow/types/form_field_value.py @@ -4,34 +4,51 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .form_field_value_type import FormFieldValueType -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore +class FormFieldValue(pydantic_v1.BaseModel): + """ + An object containing field info for a specific fieldID. + """ -class FormFieldValue(pydantic.BaseModel): - display_name: typing.Optional[str] = pydantic.Field( - alias="displayName", default=None, description="The field name displayed on the site" - ) - type: typing.Optional[FormFieldValueType] = pydantic.Field(default=None, description="The field type") - placeholder: typing.Optional[str] = pydantic.Field(default=None, description="The placeholder text for the field") - user_visible: typing.Optional[bool] = pydantic.Field( - alias="userVisible", default=None, description="Whether the field is visible to the user" - ) + display_name: typing.Optional[str] = pydantic_v1.Field(alias="displayName", default=None) + """ + The field name displayed on the site + """ + + type: typing.Optional[FormFieldValueType] = pydantic_v1.Field(default=None) + """ + The field type + """ + + placeholder: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + The placeholder text for the field + """ + + user_visible: typing.Optional[bool] = pydantic_v1.Field(alias="userVisible", default=None) + """ + Whether the field is visible to the user + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/form_list.py b/src/webflow/types/form_list.py index c3f50c5..106dacd 100644 --- a/src/webflow/types/form_list.py +++ b/src/webflow/types/form_list.py @@ -4,16 +4,12 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .form import Form from .pagination import Pagination -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class FormList(pydantic.BaseModel): +class FormList(pydantic_v1.BaseModel): forms: typing.Optional[typing.List[Form]] = None pagination: typing.Optional[Pagination] = None @@ -22,10 +18,15 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/form_response_settings.py b/src/webflow/types/form_response_settings.py index 06c1264..2a652ab 100644 --- a/src/webflow/types/form_response_settings.py +++ b/src/webflow/types/form_response_settings.py @@ -4,39 +4,50 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - - -class FormResponseSettings(pydantic.BaseModel): - send_email_confirmation: typing.Optional[bool] = pydantic.Field( - alias="sendEmailConfirmation", default=None, description="Whether to send an email confirmation to the user" - ) - redirect_url: typing.Optional[str] = pydantic.Field( - alias="redirectUrl", default=None, description="The url or path to redirect the user to after form submission" - ) - redirect_method: typing.Optional[str] = pydantic.Field( - alias="redirectMethod", - default=None, - description="The HTTP request method to use for the redirectUrl (eg. POST or GET)", - ) - redirect_action: typing.Optional[str] = pydantic.Field( - alias="redirectAction", default=None, description="The action to take after form submission" - ) + +class FormResponseSettings(pydantic_v1.BaseModel): + """ + Settings for form responses + """ + + redirect_url: typing.Optional[str] = pydantic_v1.Field(alias="redirectUrl", default=None) + """ + The url or path to redirect the user to after form submission + """ + + redirect_method: typing.Optional[str] = pydantic_v1.Field(alias="redirectMethod", default=None) + """ + The HTTP request method to use for the redirectUrl (eg. POST or GET) + """ + + redirect_action: typing.Optional[str] = pydantic_v1.Field(alias="redirectAction", default=None) + """ + The action to take after form submission + """ + + send_email_confirmation: typing.Optional[bool] = pydantic_v1.Field(alias="sendEmailConfirmation", default=None) + """ + Whether to send an email confirmation to the user + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/form_submission.py b/src/webflow/types/form_submission.py index c32d501..e55cef3 100644 --- a/src/webflow/types/form_submission.py +++ b/src/webflow/types/form_submission.py @@ -4,41 +4,56 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - - -class FormSubmission(pydantic.BaseModel): - id: typing.Optional[str] = pydantic.Field(default=None, description="The unique id of the Form submission") - display_name: typing.Optional[str] = pydantic.Field( - alias="displayName", default=None, description="The Form name displayed on the site" - ) - site_id: typing.Optional[str] = pydantic.Field( - alias="siteId", default=None, description="The unique id of the Site the Form belongs to" - ) - workspace_id: typing.Optional[str] = pydantic.Field( - alias="workspaceId", default=None, description="The unique id of the Workspace the Site belongs to" - ) - date_submitted: typing.Optional[dt.datetime] = pydantic.Field( - alias="dateSubmitted", default=None, description="Date that the Form was submitted on" - ) - form_response: typing.Optional[typing.Dict[str, typing.Any]] = pydantic.Field( - alias="formResponse", default=None, description="The data submitted in the Form" - ) + +class FormSubmission(pydantic_v1.BaseModel): + id: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + The unique id of the Form submission + """ + + display_name: typing.Optional[str] = pydantic_v1.Field(alias="displayName", default=None) + """ + The Form name displayed on the site + """ + + site_id: typing.Optional[str] = pydantic_v1.Field(alias="siteId", default=None) + """ + The unique id of the Site the Form belongs to + """ + + workspace_id: typing.Optional[str] = pydantic_v1.Field(alias="workspaceId", default=None) + """ + The unique id of the Workspace the Site belongs to + """ + + date_submitted: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="dateSubmitted", default=None) + """ + Date that the Form was submitted on + """ + + form_response: typing.Optional[typing.Dict[str, typing.Any]] = pydantic_v1.Field(alias="formResponse", default=None) + """ + The data submitted in the Form + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/form_submission_list.py b/src/webflow/types/form_submission_list.py index 78beebd..6222a6a 100644 --- a/src/webflow/types/form_submission_list.py +++ b/src/webflow/types/form_submission_list.py @@ -4,16 +4,12 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .form_submission import FormSubmission from .pagination import Pagination -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class FormSubmissionList(pydantic.BaseModel): +class FormSubmissionList(pydantic_v1.BaseModel): submissions: typing.Optional[typing.List[FormSubmission]] = None pagination: typing.Optional[Pagination] = None @@ -22,10 +18,15 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/image_node.py b/src/webflow/types/image_node.py index 019874c..89950bf 100644 --- a/src/webflow/types/image_node.py +++ b/src/webflow/types/image_node.py @@ -4,31 +4,33 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class ImageNode(pydantic.BaseModel): +class ImageNode(pydantic_v1.BaseModel): """ Represents an image within the DOM. It contains details about the image, such as its alternative text (alt) for accessibility and an asset identifier for fetching the actual image resource. Additional attributes can be associated with the image for styling or other purposes. """ alt: typing.Optional[str] = None - asset_id: typing.Optional[str] = pydantic.Field(alias="assetId", default=None) + asset_id: typing.Optional[str] = pydantic_v1.Field(alias="assetId", default=None) def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/inventory_item.py b/src/webflow/types/inventory_item.py index d1f66e9..6032815 100644 --- a/src/webflow/types/inventory_item.py +++ b/src/webflow/types/inventory_item.py @@ -4,37 +4,46 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .inventory_item_inventory_type import InventoryItemInventoryType -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class InventoryItem(pydantic.BaseModel): +class InventoryItem(pydantic_v1.BaseModel): """ The availabile inventory for an item """ - id: typing.Optional[str] = pydantic.Field(default=None, description="Unique identifier for a SKU item") - quantity: typing.Optional[float] = pydantic.Field( - default=None, description="Total quantity of items remaining in inventory (if inventoryType is finite)" - ) - inventory_type: typing.Optional[InventoryItemInventoryType] = pydantic.Field( - alias="inventoryType", default=None, description="infinite or finite" - ) + id: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + Unique identifier for a SKU item + """ + + quantity: typing.Optional[float] = pydantic_v1.Field(default=None) + """ + Total quantity of items remaining in inventory (if inventoryType is finite) + """ + + inventory_type: typing.Optional[InventoryItemInventoryType] = pydantic_v1.Field(alias="inventoryType", default=None) + """ + infinite or finite + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/list_custom_code_blocks.py b/src/webflow/types/list_custom_code_blocks.py index 20ea276..a67223a 100644 --- a/src/webflow/types/list_custom_code_blocks.py +++ b/src/webflow/types/list_custom_code_blocks.py @@ -4,16 +4,12 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .custom_code_block import CustomCodeBlock from .pagination import Pagination -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class ListCustomCodeBlocks(pydantic.BaseModel): +class ListCustomCodeBlocks(pydantic_v1.BaseModel): """ Custom Code Blocks corresponding to where scripts were applied """ @@ -26,10 +22,15 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/locale.py b/src/webflow/types/locale.py new file mode 100644 index 0000000..7989af3 --- /dev/null +++ b/src/webflow/types/locale.py @@ -0,0 +1,69 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 + + +class Locale(pydantic_v1.BaseModel): + id: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + The unique identifier for the locale. + """ + + cms_locale_id: typing.Optional[str] = pydantic_v1.Field(alias="cmsLocaleId", default=None) + """ + A CMS-specific identifier for the locale. + """ + + enabled: typing.Optional[bool] = pydantic_v1.Field(default=None) + """ + Indicates if the locale is enabled. + """ + + display_name: typing.Optional[str] = pydantic_v1.Field(alias="displayName", default=None) + """ + The display name of the locale, typically in English. + """ + + display_image_id: typing.Optional[str] = pydantic_v1.Field(alias="displayImageId", default=None) + """ + An optional ID for an image associated with the locale, nullable. + """ + + redirect: typing.Optional[bool] = pydantic_v1.Field(default=None) + """ + Determines if requests should redirect to the locale's subdirectory. + """ + + subdirectory: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + The subdirectory path for the locale, used in URLs. + """ + + tag: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + A tag or code representing the locale, often following a standard format like 'en-US'. + """ + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) + + class Config: + frozen = True + smart_union = True + allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/locales.py b/src/webflow/types/locales.py new file mode 100644 index 0000000..de37c9b --- /dev/null +++ b/src/webflow/types/locales.py @@ -0,0 +1,38 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from .locale import Locale + + +class Locales(pydantic_v1.BaseModel): + primary: typing.Optional[Locale] = pydantic_v1.Field(default=None) + """ + The primary locale for the site or application. + """ + + secondary: typing.Optional[typing.List[Locale]] = pydantic_v1.Field(default=None) + """ + A list of secondary locales available for the site or application. + """ + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) + + class Config: + frozen = True + smart_union = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/missing_scopes.py b/src/webflow/types/missing_scopes.py index 74e0a7f..a3b4b3e 100644 --- a/src/webflow/types/missing_scopes.py +++ b/src/webflow/types/missing_scopes.py @@ -1,38 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing +from .error import Error -from ..core.datetime_utils import serialize_datetime -from .error_details_item import ErrorDetailsItem - -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - - -class MissingScopes(pydantic.BaseModel): - code: typing.Optional[typing.Literal["missing_scopes"]] = None - type: typing.Optional[str] = None - message: typing.Optional[str] = pydantic.Field(default=None, description="Error message") - external_reference: typing.Optional[str] = pydantic.Field( - alias="externalReference", default=None, description="Link to more information" - ) - details: typing.Optional[typing.List[ErrorDetailsItem]] = pydantic.Field( - default=None, description="Array of errors" - ) - - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) - - class Config: - frozen = True - smart_union = True - allow_population_by_field_name = True - json_encoders = {dt.datetime: serialize_datetime} +MissingScopes = Error diff --git a/src/webflow/types/node.py b/src/webflow/types/node.py index d15cf06..66370b4 100644 --- a/src/webflow/types/node.py +++ b/src/webflow/types/node.py @@ -4,36 +4,44 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .image_node import ImageNode from .node_type import NodeType from .text_node import TextNode -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class Node(pydantic.BaseModel): +class Node(pydantic_v1.BaseModel): """ A generic representation of a content element within the Document Object Model (DOM). Each node has a unique identifier and a specific type that determines its content structure and attributes. """ - id: typing.Optional[str] = pydantic.Field(default=None, description="Node UUID") + id: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + Node UUID + """ + type: typing.Optional[NodeType] = None text: typing.Optional[TextNode] = None image: typing.Optional[ImageNode] = None - attributes: typing.Optional[typing.Dict[str, str]] = None + attributes: typing.Optional[typing.Dict[str, str]] = pydantic_v1.Field(default=None) + """ + The custom attributes of the node + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/not_enterprise_plan_site.py b/src/webflow/types/not_enterprise_plan_site.py index 9c2c607..41410c6 100644 --- a/src/webflow/types/not_enterprise_plan_site.py +++ b/src/webflow/types/not_enterprise_plan_site.py @@ -1,38 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing +from .error import Error -from ..core.datetime_utils import serialize_datetime -from .error_details_item import ErrorDetailsItem - -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - - -class NotEnterprisePlanSite(pydantic.BaseModel): - code: typing.Optional[typing.Literal["missing_scopes"]] = None - type: typing.Optional[str] = None - message: typing.Optional[str] = pydantic.Field(default=None, description="Error message") - external_reference: typing.Optional[str] = pydantic.Field( - alias="externalReference", default=None, description="Link to more information" - ) - details: typing.Optional[typing.List[ErrorDetailsItem]] = pydantic.Field( - default=None, description="Array of errors" - ) - - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) - - class Config: - frozen = True - smart_union = True - allow_population_by_field_name = True - json_encoders = {dt.datetime: serialize_datetime} +NotEnterprisePlanSite = Error diff --git a/src/webflow/types/oauth_scope.py b/src/webflow/types/oauth_scope.py index 2d49caa..59ad0fd 100644 --- a/src/webflow/types/oauth_scope.py +++ b/src/webflow/types/oauth_scope.py @@ -97,6 +97,16 @@ class OauthScope(str, enum.Enum): modify users on the site """ + WORKSPACE_READ = "workspace:read" + """ + read workspace resource data + """ + + WORKSPACE_WRITE = "workspace:write" + """ + write workspace resource data + """ + def visit( self, authorized_user_read: typing.Callable[[], T_Result], @@ -117,6 +127,8 @@ def visit( users_read: typing.Callable[[], T_Result], site_activity_read: typing.Callable[[], T_Result], users_write: typing.Callable[[], T_Result], + workspace_read: typing.Callable[[], T_Result], + workspace_write: typing.Callable[[], T_Result], ) -> T_Result: if self is OauthScope.AUTHORIZED_USER_READ: return authorized_user_read() @@ -154,3 +166,7 @@ def visit( return site_activity_read() if self is OauthScope.USERS_WRITE: return users_write() + if self is OauthScope.WORKSPACE_READ: + return workspace_read() + if self is OauthScope.WORKSPACE_WRITE: + return workspace_write() diff --git a/src/webflow/types/order.py b/src/webflow/types/order.py index 9f7cdd6..f4be90d 100644 --- a/src/webflow/types/order.py +++ b/src/webflow/types/order.py @@ -4,6 +4,7 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .order_address import OrderAddress from .order_customer_info import OrderCustomerInfo from .order_dispute_last_status import OrderDisputeLastStatus @@ -17,139 +18,177 @@ from .stripe_card import StripeCard from .stripe_details import StripeDetails -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore +class Order(pydantic_v1.BaseModel): + order_id: typing.Optional[str] = pydantic_v1.Field(alias="orderId", default=None) + """ + The order id. Will usually be 6 hex characters, but can also be 9 hex characters if the site has a very large number of Orders. Randomly assigned. + """ -class Order(pydantic.BaseModel): - order_id: typing.Optional[str] = pydantic.Field( - alias="orderId", - default=None, - description="The order id. Will usually be 6 hex characters, but can also be 9 hex characters if the site has a very large number of Orders. Randomly assigned.", - ) - status: typing.Optional[OrderStatus] = pydantic.Field(default=None, description="The status of the Order") - comment: typing.Optional[str] = pydantic.Field( - default=None, description="A comment string for this Order editable by API user (not used by Webflow)." - ) - order_comment: typing.Optional[str] = pydantic.Field( - alias="orderComment", default=None, description="A comment that the customer left when making their Order" - ) - accepted_on: typing.Optional[dt.datetime] = pydantic.Field( - alias="acceptedOn", default=None, description="The ISO8601 timestamp that an Order was placed." - ) - fulfilled_on: typing.Optional[dt.datetime] = pydantic.Field( - alias="fulfilledOn", - default=None, - description="If an Order was marked as 'fulfilled', then this is the ISO8601 timestamp when that happened.", - ) - refunded_on: typing.Optional[dt.datetime] = pydantic.Field( - alias="refundedOn", - default=None, - description="If an Order was refunded, this is the ISO8601 of when that happened.", - ) - disputed_on: typing.Optional[dt.datetime] = pydantic.Field( - alias="disputedOn", - default=None, - description="If an Order was disputed by the customer, then this key will be set with the ISO8601 timestamp that Stripe notifies Webflow. Null if not disputed.", - ) - dispute_updated_on: typing.Optional[dt.datetime] = pydantic.Field( - alias="disputeUpdatedOn", - default=None, - description="If an Order was disputed by the customer, then this key will be set with the ISO8601 timestamp of the last time that we got an update. Null if not disputed.", - ) - dispute_last_status: typing.Optional[OrderDisputeLastStatus] = pydantic.Field( - alias="disputeLastStatus", - default=None, - description="If an order was disputed by the customer, then this key will be set with the [dispute's status](https://stripe.com/docs/api#dispute_object-status).", - ) - customer_paid: typing.Optional[OrderPrice] = pydantic.Field( - alias="customerPaid", default=None, description="The total paid by the customer" - ) - net_amount: typing.Optional[OrderPrice] = pydantic.Field( - alias="netAmount", default=None, description="The net amount after application fees" - ) - application_fee: typing.Optional[OrderPrice] = pydantic.Field( - alias="applicationFee", default=None, description="The application fee assessed by the platform" - ) - all_addresses: typing.Optional[typing.List[OrderAddress]] = pydantic.Field( - alias="allAddresses", - default=None, - description="All addresses provided by the customer during the ordering flow.", - ) - shipping_address: typing.Optional[OrderAddress] = pydantic.Field( - alias="shippingAddress", default=None, description="The shipping address" - ) - billing_address: typing.Optional[OrderAddress] = pydantic.Field( - alias="billingAddress", default=None, description="The billing address" - ) - shipping_provider: typing.Optional[str] = pydantic.Field( - alias="shippingProvider", - default=None, - description="A string editable by the API user to note the shipping provider used (not used by Webflow).", - ) - shipping_tracking: typing.Optional[str] = pydantic.Field( - alias="shippingTracking", - default=None, - description="A string editable by the API user to note the shipping tracking number for the order (not used by Webflow).", - ) - shipping_tracking_url: typing.Optional[str] = pydantic.Field(alias="shippingTrackingURL", default=None) - customer_info: typing.Optional[OrderCustomerInfo] = pydantic.Field( - alias="customerInfo", default=None, description="An object with the keys `fullName` and `email`." - ) - purchased_items: typing.Optional[typing.List[OrderPurchasedItem]] = pydantic.Field( - alias="purchasedItems", default=None, description="An array of all things that the Customer purchased." - ) - purchased_items_count: typing.Optional[float] = pydantic.Field( - alias="purchasedItemsCount", default=None, description="The sum of all 'count' fields in 'purchasedItems'." + status: typing.Optional[OrderStatus] = pydantic_v1.Field(default=None) + """ + The status of the Order + """ + + comment: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + A comment string for this Order, which is editable by API user (not used by Webflow). + """ + + order_comment: typing.Optional[str] = pydantic_v1.Field(alias="orderComment", default=None) + """ + A comment that the customer left when making their Order + """ + + accepted_on: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="acceptedOn", default=None) + """ + The ISO8601 timestamp that an Order was placed. + """ + + fulfilled_on: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="fulfilledOn", default=None) + """ + When an Order is marked as 'fulfilled', this field represents the timestamp of the fulfillment in ISO8601 format. Otherwise, it is null. + """ + + refunded_on: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="refundedOn", default=None) + """ + When an Order is marked as 'refunded', this field represents the timestamp of the fulfillment in ISO8601 format. Otherwise, it is null. + """ + + disputed_on: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="disputedOn", default=None) + """ + When an Order is marked as 'disputed', this field represents the timestamp of the fulfillment in ISO8601 format. Otherwise, it is null. + """ + + dispute_updated_on: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="disputeUpdatedOn", default=None) + """ + If an Order has been disputed by the customer, this key will be set to the ISO8601 timestamp of the last update received. If the Order is not disputed, the key will be null. + """ + + dispute_last_status: typing.Optional[OrderDisputeLastStatus] = pydantic_v1.Field( + alias="disputeLastStatus", default=None ) - stripe_details: typing.Optional[StripeDetails] = pydantic.Field(alias="stripeDetails", default=None) - stripe_card: typing.Optional[StripeCard] = pydantic.Field(alias="stripeCard", default=None) - paypal_details: typing.Optional[PaypalDetails] = pydantic.Field(alias="paypalDetails", default=None) - custom_data: typing.Optional[typing.List[typing.Dict[str, typing.Any]]] = pydantic.Field( - alias="customData", - default=None, - description="An array of additional inputs for custom order data gathering. Each object in the array represents an input with a name, and a textInput, textArea, or checkbox value.", + """ + If an order was disputed by the customer, then this key will be set with the [dispute's status](https://stripe.com/docs/api#dispute_object-status). + """ + + customer_paid: typing.Optional[OrderPrice] = pydantic_v1.Field(alias="customerPaid", default=None) + """ + The total paid by the customer + """ + + net_amount: typing.Optional[OrderPrice] = pydantic_v1.Field(alias="netAmount", default=None) + """ + The net amount after application fees + """ + + application_fee: typing.Optional[OrderPrice] = pydantic_v1.Field(alias="applicationFee", default=None) + """ + The application fee assessed by the platform + """ + + all_addresses: typing.Optional[typing.List[OrderAddress]] = pydantic_v1.Field(alias="allAddresses", default=None) + """ + All addresses provided by the customer during the ordering flow. + """ + + shipping_address: typing.Optional[OrderAddress] = pydantic_v1.Field(alias="shippingAddress", default=None) + """ + The shipping address + """ + + billing_address: typing.Optional[OrderAddress] = pydantic_v1.Field(alias="billingAddress", default=None) + """ + The billing address + """ + + shipping_provider: typing.Optional[str] = pydantic_v1.Field(alias="shippingProvider", default=None) + """ + A string editable by the API user to note the shipping provider used (not used by Webflow). + """ + + shipping_tracking: typing.Optional[str] = pydantic_v1.Field(alias="shippingTracking", default=None) + """ + A string editable by the API user to note the shipping tracking number for the order (not used by Webflow). + """ + + shipping_tracking_url: typing.Optional[str] = pydantic_v1.Field(alias="shippingTrackingURL", default=None) + customer_info: typing.Optional[OrderCustomerInfo] = pydantic_v1.Field(alias="customerInfo", default=None) + """ + An object with the keys `fullName` and `email`. + """ + + purchased_items: typing.Optional[typing.List[OrderPurchasedItem]] = pydantic_v1.Field( + alias="purchasedItems", default=None ) + """ + An array of all things that the Customer purchased. + """ + + purchased_items_count: typing.Optional[float] = pydantic_v1.Field(alias="purchasedItemsCount", default=None) + """ + The sum of all 'count' fields in 'purchasedItems'. + """ + + stripe_details: typing.Optional[StripeDetails] = pydantic_v1.Field(alias="stripeDetails", default=None) + stripe_card: typing.Optional[StripeCard] = pydantic_v1.Field(alias="stripeCard", default=None) + paypal_details: typing.Optional[PaypalDetails] = pydantic_v1.Field(alias="paypalDetails", default=None) + custom_data: typing.Optional[typing.List[typing.Dict[str, typing.Any]]] = pydantic_v1.Field( + alias="customData", default=None + ) + """ + An array of additional inputs for custom order data gathering. Each object in the array represents an input with a name, and a textInput, textArea, or checkbox value. + """ + metadata: typing.Optional[OrderMetadata] = None - is_customer_deleted: typing.Optional[bool] = pydantic.Field( - alias="isCustomerDeleted", - default=None, - description="A boolean indicating whether the customer has been deleted from the site.", - ) - is_shipping_required: typing.Optional[bool] = pydantic.Field( - alias="isShippingRequired", - default=None, - description="A boolean indicating whether the order contains one or more purchased items that require shipping.", - ) - has_downloads: typing.Optional[bool] = pydantic.Field( - alias="hasDownloads", - default=None, - description="A boolean indicating whether the order contains one or more purchased items that are downloadable.", - ) - payment_processor: typing.Optional[str] = pydantic.Field( - alias="paymentProcessor", - default=None, - description="A string indicating the payment processor used for this order.", - ) - totals: typing.Optional[OrderTotals] = pydantic.Field( - default=None, description="An object describing various pricing totals" - ) - download_files: typing.Optional[typing.List[OrderDownloadFilesItem]] = pydantic.Field( - alias="downloadFiles", default=None, description="An array of downloadable file objects." + is_customer_deleted: typing.Optional[bool] = pydantic_v1.Field(alias="isCustomerDeleted", default=None) + """ + A boolean indicating whether the customer has been deleted from the site. + """ + + is_shipping_required: typing.Optional[bool] = pydantic_v1.Field(alias="isShippingRequired", default=None) + """ + A boolean indicating whether the order contains one or more purchased items that require shipping. + """ + + has_downloads: typing.Optional[bool] = pydantic_v1.Field(alias="hasDownloads", default=None) + """ + A boolean indicating whether the order contains one or more purchased items that are downloadable. + """ + + payment_processor: typing.Optional[str] = pydantic_v1.Field(alias="paymentProcessor", default=None) + """ + A string indicating the payment processor used for this order. + """ + + totals: typing.Optional[OrderTotals] = pydantic_v1.Field(default=None) + """ + An object describing various pricing totals + """ + + download_files: typing.Optional[typing.List[OrderDownloadFilesItem]] = pydantic_v1.Field( + alias="downloadFiles", default=None ) + """ + An array of downloadable file objects. + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/order_address.py b/src/webflow/types/order_address.py index a22a3de..5e7ec60 100644 --- a/src/webflow/types/order_address.py +++ b/src/webflow/types/order_address.py @@ -4,50 +4,77 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .order_address_japan_type import OrderAddressJapanType from .order_address_type import OrderAddressType -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class OrderAddress(pydantic.BaseModel): +class OrderAddress(pydantic_v1.BaseModel): """ A customer address """ - type: typing.Optional[OrderAddressType] = pydantic.Field( - default=None, description="The type of the order address (billing or shipping)" - ) - japan_type: typing.Optional[OrderAddressJapanType] = pydantic.Field( - alias="japanType", default=None, description="Japan-only address format" - ) - addressee: typing.Optional[str] = pydantic.Field(default=None, description="Display name on the address") - line_1: typing.Optional[str] = pydantic.Field( - alias="line1", default=None, description="The first line of the address" - ) - line_2: typing.Optional[str] = pydantic.Field( - alias="line2", default=None, description="The second line of the address" - ) - city: typing.Optional[str] = pydantic.Field(default=None, description="The city of the address.") - state: typing.Optional[str] = pydantic.Field(default=None, description="The state or province of the address") - country: typing.Optional[str] = pydantic.Field(default=None, description="The country of the address") - postal_code: typing.Optional[str] = pydantic.Field( - alias="postalCode", default=None, description="The postal code of the address" - ) + type: typing.Optional[OrderAddressType] = pydantic_v1.Field(default=None) + """ + The type of the order address (billing or shipping) + """ + + japan_type: typing.Optional[OrderAddressJapanType] = pydantic_v1.Field(alias="japanType", default=None) + """ + Represents a Japan-only address format. This field will only appear on orders placed from Japan. + """ + + addressee: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + Display name on the address + """ + + line_1: typing.Optional[str] = pydantic_v1.Field(alias="line1", default=None) + """ + The first line of the address + """ + + line_2: typing.Optional[str] = pydantic_v1.Field(alias="line2", default=None) + """ + The second line of the address + """ + + city: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + The city of the address. + """ + + state: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + The state or province of the address + """ + + country: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + The country of the address + """ + + postal_code: typing.Optional[str] = pydantic_v1.Field(alias="postalCode", default=None) + """ + The postal code of the address + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/order_address_japan_type.py b/src/webflow/types/order_address_japan_type.py index 053942b..648e1a4 100644 --- a/src/webflow/types/order_address_japan_type.py +++ b/src/webflow/types/order_address_japan_type.py @@ -8,7 +8,7 @@ class OrderAddressJapanType(str, enum.Enum): """ - Japan-only address format + Represents a Japan-only address format. This field will only appear on orders placed from Japan. """ KANA = "kana" diff --git a/src/webflow/types/order_customer_info.py b/src/webflow/types/order_customer_info.py index e0486d2..1527e4a 100644 --- a/src/webflow/types/order_customer_info.py +++ b/src/webflow/types/order_customer_info.py @@ -4,33 +4,40 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class OrderCustomerInfo(pydantic.BaseModel): +class OrderCustomerInfo(pydantic_v1.BaseModel): """ An object with the keys `fullName` and `email`. """ - full_name: typing.Optional[str] = pydantic.Field( - alias="fullName", default=None, description="The full name of the Customer" - ) - email: typing.Optional[str] = pydantic.Field(default=None, description="The Customer's email address") + full_name: typing.Optional[str] = pydantic_v1.Field(alias="fullName", default=None) + """ + The full name of the Customer + """ + + email: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + The Customer's email address + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/order_download_files_item.py b/src/webflow/types/order_download_files_item.py index 15a3210..e910b46 100644 --- a/src/webflow/types/order_download_files_item.py +++ b/src/webflow/types/order_download_files_item.py @@ -4,33 +4,39 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore +class OrderDownloadFilesItem(pydantic_v1.BaseModel): + id: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + The unique identifier for the downloadable file + """ -class OrderDownloadFilesItem(pydantic.BaseModel): - id: typing.Optional[str] = pydantic.Field( - default=None, description="The unique identifier for the downloadable file" - ) - name: typing.Optional[str] = pydantic.Field( - default=None, description="The user-facing name for the downloadable file" - ) - url: typing.Optional[str] = pydantic.Field( - default=None, description="The hosted location for the downloadable file" - ) + name: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + The user-facing name for the downloadable file + """ + + url: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + The hosted location for the downloadable file + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/order_list.py b/src/webflow/types/order_list.py index 2ad1b84..fe867c8 100644 --- a/src/webflow/types/order_list.py +++ b/src/webflow/types/order_list.py @@ -4,21 +4,21 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .order import Order from .pagination import Pagination -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class OrderList(pydantic.BaseModel): +class OrderList(pydantic_v1.BaseModel): """ Results from order list """ - items: typing.Optional[typing.List[Order]] = pydantic.Field(default=None, description="List of orders") + orders: typing.Optional[typing.List[Order]] = pydantic_v1.Field(default=None) + """ + List of orders + """ + pagination: typing.Optional[Pagination] = None def json(self, **kwargs: typing.Any) -> str: @@ -26,10 +26,15 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/order_metadata.py b/src/webflow/types/order_metadata.py index d37fc38..b1ebcd8 100644 --- a/src/webflow/types/order_metadata.py +++ b/src/webflow/types/order_metadata.py @@ -4,26 +4,28 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class OrderMetadata(pydantic.BaseModel): - is_buy_now: typing.Optional[bool] = pydantic.Field(alias="isBuyNow", default=None) +class OrderMetadata(pydantic_v1.BaseModel): + is_buy_now: typing.Optional[bool] = pydantic_v1.Field(alias="isBuyNow", default=None) def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/order_price.py b/src/webflow/types/order_price.py index 36012d1..28be474 100644 --- a/src/webflow/types/order_price.py +++ b/src/webflow/types/order_price.py @@ -4,31 +4,39 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore +class OrderPrice(pydantic_v1.BaseModel): + unit: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + The three-letter ISO currency code + """ -class OrderPrice(pydantic.BaseModel): - unit: typing.Optional[str] = pydantic.Field(default=None, description="The three-letter ISO currency code") - value: typing.Optional[str] = pydantic.Field( - default=None, description="The numeric value in the base unit of the currency" - ) - string: typing.Optional[str] = pydantic.Field( - default=None, description="The user-facing string representation of the amount" - ) + value: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + The numeric value in the base unit of the currency + """ + + string: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + The user-facing string representation of the amount + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/order_purchased_item.py b/src/webflow/types/order_purchased_item.py index f2250aa..a35a732 100644 --- a/src/webflow/types/order_purchased_item.py +++ b/src/webflow/types/order_purchased_item.py @@ -4,69 +4,105 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .order_price import OrderPrice from .order_purchased_item_variant_image import OrderPurchasedItemVariantImage -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class OrderPurchasedItem(pydantic.BaseModel): +class OrderPurchasedItem(pydantic_v1.BaseModel): """ An Item that was purchased """ - count: typing.Optional[float] = pydantic.Field(default=None, description="Number of Item purchased.") - row_total: typing.Optional[OrderPrice] = pydantic.Field( - alias="rowTotal", default=None, description="The total for the row" - ) - product_id: typing.Optional[str] = pydantic.Field( - alias="productId", default=None, description="The unique identifier for the Product" - ) - product_name: typing.Optional[str] = pydantic.Field( - alias="productName", default=None, description="User-facing name of the Product" - ) - product_slug: typing.Optional[str] = pydantic.Field( - alias="productSlug", default=None, description="Slug for the Product" - ) - variant_id: typing.Optional[str] = pydantic.Field( - alias="variantId", default=None, description="Identifier for the Product Variant (SKU)" - ) - variant_name: typing.Optional[str] = pydantic.Field( - alias="variantName", default=None, description="User-facing name of the Product Variant (SKU)" - ) - variant_slug: typing.Optional[str] = pydantic.Field( - alias="variantSlug", default=None, description="Slug for the Product Variant (SKU)" - ) - variant_image: typing.Optional[OrderPurchasedItemVariantImage] = pydantic.Field(alias="variantImage", default=None) - variant_price: typing.Optional[OrderPrice] = pydantic.Field( - alias="variantPrice", default=None, description="The price corresponding to the variant" - ) - weight: typing.Optional[float] = pydantic.Field( - default=None, description="The physical weight of the variant if provided, or null" - ) - width: typing.Optional[float] = pydantic.Field( - default=None, description="The physical width of the variant if provided, or null" - ) - height: typing.Optional[float] = pydantic.Field( - default=None, description="The physical height of the variant if provided, or null" - ) - length: typing.Optional[float] = pydantic.Field( - default=None, description="The physical length of the variant if provided, or null" + count: typing.Optional[float] = pydantic_v1.Field(default=None) + """ + Number of Item purchased. + """ + + row_total: typing.Optional[OrderPrice] = pydantic_v1.Field(alias="rowTotal", default=None) + """ + The total for the row + """ + + product_id: typing.Optional[str] = pydantic_v1.Field(alias="productId", default=None) + """ + The unique identifier for the Product + """ + + product_name: typing.Optional[str] = pydantic_v1.Field(alias="productName", default=None) + """ + User-facing name of the Product + """ + + product_slug: typing.Optional[str] = pydantic_v1.Field(alias="productSlug", default=None) + """ + Slug for the Product + """ + + variant_id: typing.Optional[str] = pydantic_v1.Field(alias="variantId", default=None) + """ + Identifier for the Product Variant (SKU) + """ + + variant_name: typing.Optional[str] = pydantic_v1.Field(alias="variantName", default=None) + """ + User-facing name of the Product Variant (SKU) + """ + + variant_slug: typing.Optional[str] = pydantic_v1.Field(alias="variantSlug", default=None) + """ + Slug for the Product Variant (SKU) + """ + + variant_sku: typing.Optional[str] = pydantic_v1.Field(alias="variantSKU", default=None) + """ + The user-defined custom SKU of the Product Variant (SKU) + """ + + variant_image: typing.Optional[OrderPurchasedItemVariantImage] = pydantic_v1.Field( + alias="variantImage", default=None ) + variant_price: typing.Optional[OrderPrice] = pydantic_v1.Field(alias="variantPrice", default=None) + """ + The price corresponding to the variant + """ + + weight: typing.Optional[float] = pydantic_v1.Field(default=None) + """ + The physical weight of the variant if provided, or null + """ + + width: typing.Optional[float] = pydantic_v1.Field(default=None) + """ + The physical width of the variant if provided, or null + """ + + height: typing.Optional[float] = pydantic_v1.Field(default=None) + """ + The physical height of the variant if provided, or null + """ + + length: typing.Optional[float] = pydantic_v1.Field(default=None) + """ + The physical length of the variant if provided, or null + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/order_purchased_item_variant_image.py b/src/webflow/types/order_purchased_item_variant_image.py index 0b31d99..837ab2d 100644 --- a/src/webflow/types/order_purchased_item_variant_image.py +++ b/src/webflow/types/order_purchased_item_variant_image.py @@ -4,16 +4,16 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .order_purchased_item_variant_image_file import OrderPurchasedItemVariantImageFile -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore +class OrderPurchasedItemVariantImage(pydantic_v1.BaseModel): + url: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + The hosted location for the Variant's image + """ -class OrderPurchasedItemVariantImage(pydantic.BaseModel): - url: typing.Optional[str] = pydantic.Field(default=None, description="The hosted location for the Variant's image") file: typing.Optional[OrderPurchasedItemVariantImageFile] = None def json(self, **kwargs: typing.Any) -> str: @@ -21,10 +21,15 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/order_purchased_item_variant_image_file.py b/src/webflow/types/order_purchased_item_variant_image_file.py index 9d73a2d..b6c273f 100644 --- a/src/webflow/types/order_purchased_item_variant_image_file.py +++ b/src/webflow/types/order_purchased_item_variant_image_file.py @@ -4,41 +4,64 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .order_purchased_item_variant_image_file_variants_item import OrderPurchasedItemVariantImageFileVariantsItem -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore +class OrderPurchasedItemVariantImageFile(pydantic_v1.BaseModel): + size: typing.Optional[float] = pydantic_v1.Field(default=None) + """ + The image size in bytes + """ -class OrderPurchasedItemVariantImageFile(pydantic.BaseModel): - size: typing.Optional[float] = pydantic.Field(default=None, description="The image size in bytes") - original_file_name: typing.Optional[str] = pydantic.Field( - alias="originalFileName", default=None, description="the original name of the image" - ) - created_on: typing.Optional[dt.datetime] = pydantic.Field( - alias="createdOn", default=None, description="The creation timestamp of the image" - ) - content_type: typing.Optional[str] = pydantic.Field( - alias="contentType", default=None, description="The MIME type of the image" - ) - width: typing.Optional[int] = pydantic.Field(default=None, description="The image width in pixels") - height: typing.Optional[int] = pydantic.Field(default=None, description="The image height in pixels") - variants: typing.Optional[typing.List[OrderPurchasedItemVariantImageFileVariantsItem]] = pydantic.Field( - default=None, description="Variants of the supplied image" + original_file_name: typing.Optional[str] = pydantic_v1.Field(alias="originalFileName", default=None) + """ + the original name of the image + """ + + created_on: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="createdOn", default=None) + """ + The creation timestamp of the image + """ + + content_type: typing.Optional[str] = pydantic_v1.Field(alias="contentType", default=None) + """ + The MIME type of the image + """ + + width: typing.Optional[int] = pydantic_v1.Field(default=None) + """ + The image width in pixels + """ + + height: typing.Optional[int] = pydantic_v1.Field(default=None) + """ + The image height in pixels + """ + + variants: typing.Optional[typing.List[OrderPurchasedItemVariantImageFileVariantsItem]] = pydantic_v1.Field( + default=None ) + """ + Variants of the supplied image + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/order_purchased_item_variant_image_file_variants_item.py b/src/webflow/types/order_purchased_item_variant_image_file_variants_item.py index fc37a0d..687898b 100644 --- a/src/webflow/types/order_purchased_item_variant_image_file_variants_item.py +++ b/src/webflow/types/order_purchased_item_variant_image_file_variants_item.py @@ -4,30 +4,47 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore +class OrderPurchasedItemVariantImageFileVariantsItem(pydantic_v1.BaseModel): + url: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + The hosted location for the Variant's image + """ -class OrderPurchasedItemVariantImageFileVariantsItem(pydantic.BaseModel): - url: typing.Optional[str] = pydantic.Field(default=None, description="The hosted location for the Variant's image") - original_file_name: typing.Optional[str] = pydantic.Field(alias="originalFileName", default=None) - size: typing.Optional[float] = pydantic.Field(default=None, description="The image size in bytes") - width: typing.Optional[int] = pydantic.Field(default=None, description="The image width in pixels") - height: typing.Optional[int] = pydantic.Field(default=None, description="The image height in pixels") + original_file_name: typing.Optional[str] = pydantic_v1.Field(alias="originalFileName", default=None) + size: typing.Optional[float] = pydantic_v1.Field(default=None) + """ + The image size in bytes + """ + + width: typing.Optional[int] = pydantic_v1.Field(default=None) + """ + The image width in pixels + """ + + height: typing.Optional[int] = pydantic_v1.Field(default=None) + """ + The image height in pixels + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/order_totals.py b/src/webflow/types/order_totals.py index ef88075..bed4a4f 100644 --- a/src/webflow/types/order_totals.py +++ b/src/webflow/types/order_totals.py @@ -4,35 +4,45 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .order_price import OrderPrice from .order_totals_extras_item import OrderTotalsExtrasItem -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class OrderTotals(pydantic.BaseModel): +class OrderTotals(pydantic_v1.BaseModel): """ An object describing various pricing totals """ - subtotal: typing.Optional[OrderPrice] = pydantic.Field(default=None, description="The subtotal price") - extras: typing.Optional[typing.List[OrderTotalsExtrasItem]] = pydantic.Field( - default=None, description="An array of extra items, includes discounts, shipping, and taxes." - ) - total: typing.Optional[OrderPrice] = pydantic.Field(default=None, description="The total price") + subtotal: typing.Optional[OrderPrice] = pydantic_v1.Field(default=None) + """ + The subtotal price + """ + + extras: typing.Optional[typing.List[OrderTotalsExtrasItem]] = pydantic_v1.Field(default=None) + """ + An array of extra items, includes discounts, shipping, and taxes. + """ + + total: typing.Optional[OrderPrice] = pydantic_v1.Field(default=None) + """ + The total price + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/order_totals_extras_item.py b/src/webflow/types/order_totals_extras_item.py index e2a70e0..7c0b399 100644 --- a/src/webflow/types/order_totals_extras_item.py +++ b/src/webflow/types/order_totals_extras_item.py @@ -4,40 +4,50 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .order_price import OrderPrice from .order_totals_extras_item_type import OrderTotalsExtrasItemType -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class OrderTotalsExtrasItem(pydantic.BaseModel): +class OrderTotalsExtrasItem(pydantic_v1.BaseModel): """ Extra order items, includes discounts, shipping, and taxes. """ - type: typing.Optional[OrderTotalsExtrasItemType] = pydantic.Field( - default=None, description="The type of extra item this is." - ) - name: typing.Optional[str] = pydantic.Field( - default=None, description="A human-readable (but English) name for this extra charge." - ) - description: typing.Optional[str] = pydantic.Field( - default=None, description="A human-readable (but English) description of this extra charge." - ) - price: typing.Optional[OrderPrice] = pydantic.Field(default=None, description="The price for the item") + type: typing.Optional[OrderTotalsExtrasItemType] = pydantic_v1.Field(default=None) + """ + The type of extra item this is. + """ + + name: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + A human-readable (but English) name for this extra charge. + """ + + description: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + A human-readable (but English) description of this extra charge. + """ + + price: typing.Optional[OrderPrice] = pydantic_v1.Field(default=None) + """ + The price for the item + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/page.py b/src/webflow/types/page.py index f67e4b2..4995ea4 100644 --- a/src/webflow/types/page.py +++ b/src/webflow/types/page.py @@ -4,67 +4,102 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .page_open_graph import PageOpenGraph from .page_seo import PageSeo -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class Page(pydantic.BaseModel): +class Page(pydantic_v1.BaseModel): """ The Page object """ - id: typing.Optional[str] = pydantic.Field(default=None, description="Unique identifier for the Page") - site_id: typing.Optional[str] = pydantic.Field( - alias="siteId", default=None, description="Unique identifier for the Site" - ) - title: typing.Optional[str] = pydantic.Field(default=None, description="Title of the Page") - slug: typing.Optional[str] = pydantic.Field(default=None, description="slug of the Page (derived from title)") - parent_id: typing.Optional[str] = pydantic.Field( - alias="parentId", default=None, description="Identifier of the parent folder" - ) - collection_id: typing.Optional[str] = pydantic.Field( - alias="collectionId", - default=None, - description="Unique identifier for a linked Collection, value will be null if the Page is not part of a Collection.", - ) - created_on: typing.Optional[dt.datetime] = pydantic.Field( - alias="createdOn", default=None, description="The date the Page was created" - ) - last_updated: typing.Optional[dt.datetime] = pydantic.Field( - alias="lastUpdated", default=None, description="The date the Page was most recently updated" - ) - archived: typing.Optional[bool] = pydantic.Field(default=None, description="Whether the Page has been archived") - draft: typing.Optional[bool] = pydantic.Field(default=None, description="Whether the Page is a draft") - can_branch: typing.Optional[bool] = pydantic.Field( - alias="canBranch", - default=None, - description="Indicates whether the Page supports [Page Branching](https://university.webflow.com/lesson/page-branching)", - ) - is_members_only: typing.Optional[bool] = pydantic.Field( - alias="isMembersOnly", - default=None, - description="Indicates whether the Page is restricted by [Memberships Controls](https://university.webflow.com/lesson/webflow-memberships-overview#how-to-manage-page-restrictions)", - ) - seo: typing.Optional[PageSeo] = pydantic.Field(default=None, description="SEO-related fields for the Page") - open_graph: typing.Optional[PageOpenGraph] = pydantic.Field( - alias="openGraph", default=None, description="Open Graph fields for the Page" - ) + id: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + Unique identifier for the Page + """ + + site_id: typing.Optional[str] = pydantic_v1.Field(alias="siteId", default=None) + """ + Unique identifier for the Site + """ + + title: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + Title of the Page + """ + + slug: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + slug of the Page (derived from title) + """ + + parent_id: typing.Optional[str] = pydantic_v1.Field(alias="parentId", default=None) + """ + Identifier of the parent folder + """ + + collection_id: typing.Optional[str] = pydantic_v1.Field(alias="collectionId", default=None) + """ + Unique identifier for a linked Collection, value will be null if the Page is not part of a Collection. + """ + + created_on: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="createdOn", default=None) + """ + The date the Page was created + """ + + last_updated: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="lastUpdated", default=None) + """ + The date the Page was most recently updated + """ + + archived: typing.Optional[bool] = pydantic_v1.Field(default=None) + """ + Whether the Page has been archived + """ + + draft: typing.Optional[bool] = pydantic_v1.Field(default=None) + """ + Whether the Page is a draft + """ + + can_branch: typing.Optional[bool] = pydantic_v1.Field(alias="canBranch", default=None) + """ + Indicates whether the Page supports [Page Branching](https://university.webflow.com/lesson/page-branching) + """ + + is_members_only: typing.Optional[bool] = pydantic_v1.Field(alias="isMembersOnly", default=None) + """ + Indicates whether the Page is restricted by [Memberships Controls](https://university.webflow.com/lesson/webflow-memberships-overview#how-to-manage-page-restrictions) + """ + + seo: typing.Optional[PageSeo] = pydantic_v1.Field(default=None) + """ + SEO-related fields for the Page + """ + + open_graph: typing.Optional[PageOpenGraph] = pydantic_v1.Field(alias="openGraph", default=None) + """ + Open Graph fields for the Page + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/page_details.py b/src/webflow/types/page_details.py new file mode 100644 index 0000000..6efa48e --- /dev/null +++ b/src/webflow/types/page_details.py @@ -0,0 +1,115 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from .page_details_open_graph import PageDetailsOpenGraph +from .page_details_seo import PageDetailsSeo + + +class PageDetails(pydantic_v1.BaseModel): + """ + The Page object + """ + + id: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + Unique identifier for the Page + """ + + site_id: typing.Optional[str] = pydantic_v1.Field(alias="siteId", default=None) + """ + Unique identifier for the Site + """ + + title: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + Title of the Page + """ + + slug: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + slug of the Page (derived from title) + """ + + parent_id: typing.Optional[str] = pydantic_v1.Field(alias="parentId", default=None) + """ + Identifier of the parent folder + """ + + collection_id: typing.Optional[str] = pydantic_v1.Field(alias="collectionId", default=None) + """ + Unique identifier for a linked Collection, value will be null if the Page is not part of a Collection. + """ + + created_on: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="createdOn", default=None) + """ + The date the Page was created + """ + + last_updated: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="lastUpdated", default=None) + """ + The date the Page was most recently updated + """ + + archived: typing.Optional[bool] = pydantic_v1.Field(default=None) + """ + Whether the Page has been archived + """ + + draft: typing.Optional[bool] = pydantic_v1.Field(default=None) + """ + Whether the Page is a draft + """ + + can_branch: typing.Optional[bool] = pydantic_v1.Field(alias="canBranch", default=None) + """ + Indicates whether the Page supports [Page Branching](https://university.webflow.com/lesson/page-branching) + """ + + is_members_only: typing.Optional[bool] = pydantic_v1.Field(alias="isMembersOnly", default=None) + """ + Indicates whether the Page is restricted by [Memberships Controls](https://university.webflow.com/lesson/webflow-memberships-overview#how-to-manage-page-restrictions) + """ + + seo: typing.Optional[PageDetailsSeo] = pydantic_v1.Field(default=None) + """ + SEO-related fields for the Page + """ + + open_graph: typing.Optional[PageDetailsOpenGraph] = pydantic_v1.Field(alias="openGraph", default=None) + """ + Open Graph fields for the Page + """ + + locale_id: typing.Optional[str] = pydantic_v1.Field(alias="localeId", default=None) + """ + Unique ID of the page locale + """ + + published_path: typing.Optional[str] = pydantic_v1.Field(alias="publishedPath", default=None) + """ + Relative path of the published page URL + """ + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) + + class Config: + frozen = True + smart_union = True + allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/page_details_open_graph.py b/src/webflow/types/page_details_open_graph.py new file mode 100644 index 0000000..6d82c28 --- /dev/null +++ b/src/webflow/types/page_details_open_graph.py @@ -0,0 +1,53 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 + + +class PageDetailsOpenGraph(pydantic_v1.BaseModel): + """ + Open Graph fields for the Page + """ + + title: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + The title supplied to Open Graph annotations + """ + + title_copied: typing.Optional[bool] = pydantic_v1.Field(alias="titleCopied", default=None) + """ + Indicates the Open Graph title was copied from the SEO title + """ + + description: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + The description supplied to Open Graph annotations + """ + + description_copied: typing.Optional[bool] = pydantic_v1.Field(alias="descriptionCopied", default=None) + """ + Indicates the Open Graph description was copied from the SEO description + """ + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) + + class Config: + frozen = True + smart_union = True + allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/page_details_seo.py b/src/webflow/types/page_details_seo.py new file mode 100644 index 0000000..7038e39 --- /dev/null +++ b/src/webflow/types/page_details_seo.py @@ -0,0 +1,41 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 + + +class PageDetailsSeo(pydantic_v1.BaseModel): + """ + SEO-related fields for the Page + """ + + title: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + The Page title shown in search engine results + """ + + description: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + The Page description shown in search engine results + """ + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) + + class Config: + frozen = True + smart_union = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/page_list.py b/src/webflow/types/page_list.py index 3ba1a63..11c5420 100644 --- a/src/webflow/types/page_list.py +++ b/src/webflow/types/page_list.py @@ -4,16 +4,12 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .page import Page from .pagination import Pagination -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class PageList(pydantic.BaseModel): +class PageList(pydantic_v1.BaseModel): """ The Page object """ @@ -26,10 +22,15 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/page_open_graph.py b/src/webflow/types/page_open_graph.py index 2c7f5fb..317ba4b 100644 --- a/src/webflow/types/page_open_graph.py +++ b/src/webflow/types/page_open_graph.py @@ -4,43 +4,50 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class PageOpenGraph(pydantic.BaseModel): +class PageOpenGraph(pydantic_v1.BaseModel): """ Open Graph fields for the Page """ - title: typing.Optional[str] = pydantic.Field( - default=None, description="The title supplied to Open Graph annotations" - ) - title_copied: typing.Optional[bool] = pydantic.Field( - alias="titleCopied", default=None, description="Indicates the Open Graph title was copied from the SEO title" - ) - description: typing.Optional[str] = pydantic.Field( - default=None, description="The description supplied to Open Graph annotations" - ) - description_copied: typing.Optional[bool] = pydantic.Field( - alias="descriptionCopied", - default=None, - description="Indicates the Open Graph description was copied from the SEO description", - ) + title: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + The title supplied to Open Graph annotations + """ + + title_copied: typing.Optional[bool] = pydantic_v1.Field(alias="titleCopied", default=None) + """ + Indicates the Open Graph title was copied from the SEO title + """ + + description: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + The description supplied to Open Graph annotations + """ + + description_copied: typing.Optional[bool] = pydantic_v1.Field(alias="descriptionCopied", default=None) + """ + Indicates the Open Graph description was copied from the SEO description + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/page_seo.py b/src/webflow/types/page_seo.py index 091d1e9..02a9d3e 100644 --- a/src/webflow/types/page_seo.py +++ b/src/webflow/types/page_seo.py @@ -4,34 +4,38 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class PageSeo(pydantic.BaseModel): +class PageSeo(pydantic_v1.BaseModel): """ SEO-related fields for the Page """ - title: typing.Optional[str] = pydantic.Field( - default=None, description="The Page title shown in search engine results" - ) - description: typing.Optional[str] = pydantic.Field( - default=None, description="The Page description shown in search engine results" - ) + title: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + The Page title shown in search engine results + """ + + description: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + The Page description shown in search engine results + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/pagination.py b/src/webflow/types/pagination.py index b8bb3b6..16fed76 100644 --- a/src/webflow/types/pagination.py +++ b/src/webflow/types/pagination.py @@ -4,31 +4,43 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class Pagination(pydantic.BaseModel): +class Pagination(pydantic_v1.BaseModel): """ Pagination object """ - limit: typing.Optional[float] = pydantic.Field(default=None, description="The limit used for pagination") - offset: typing.Optional[float] = pydantic.Field(default=None, description="The offset used for pagination") - total: typing.Optional[float] = pydantic.Field(default=None, description="The total number of records") + limit: typing.Optional[float] = pydantic_v1.Field(default=None) + """ + The limit used for pagination + """ + + offset: typing.Optional[float] = pydantic_v1.Field(default=None) + """ + The offset used for pagination + """ + + total: typing.Optional[float] = pydantic_v1.Field(default=None) + """ + The total number of records + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/paypal_details.py b/src/webflow/types/paypal_details.py index 80afce3..3e8642c 100644 --- a/src/webflow/types/paypal_details.py +++ b/src/webflow/types/paypal_details.py @@ -4,43 +4,56 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - - -class PaypalDetails(pydantic.BaseModel): - order_id: typing.Optional[str] = pydantic.Field( - alias="orderId", default=None, description="PayPal order identifier" - ) - payer_id: typing.Optional[str] = pydantic.Field( - alias="payerId", default=None, description="PayPal payer identifier" - ) - capture_id: typing.Optional[str] = pydantic.Field( - alias="captureId", default=None, description="PayPal capture identifier" - ) - refund_id: typing.Optional[str] = pydantic.Field( - alias="refundId", default=None, description="PayPal refund identifier" - ) - refund_reason: typing.Optional[str] = pydantic.Field( - alias="refundReason", default=None, description="PayPal-issued reason for the refund" - ) - dispute_id: typing.Optional[str] = pydantic.Field( - alias="disputeId", default=None, description="PayPal dispute identifier" - ) + +class PaypalDetails(pydantic_v1.BaseModel): + order_id: typing.Optional[str] = pydantic_v1.Field(alias="orderId", default=None) + """ + PayPal order identifier + """ + + payer_id: typing.Optional[str] = pydantic_v1.Field(alias="payerId", default=None) + """ + PayPal payer identifier + """ + + capture_id: typing.Optional[str] = pydantic_v1.Field(alias="captureId", default=None) + """ + PayPal capture identifier + """ + + refund_id: typing.Optional[str] = pydantic_v1.Field(alias="refundId", default=None) + """ + PayPal refund identifier + """ + + refund_reason: typing.Optional[str] = pydantic_v1.Field(alias="refundReason", default=None) + """ + PayPal-issued reason for the refund + """ + + dispute_id: typing.Optional[str] = pydantic_v1.Field(alias="disputeId", default=None) + """ + PayPal dispute identifier + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/product.py b/src/webflow/types/product.py index 81e7372..c557bd3 100644 --- a/src/webflow/types/product.py +++ b/src/webflow/types/product.py @@ -4,47 +4,68 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .product_field_data import ProductFieldData -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class Product(pydantic.BaseModel): +class Product(pydantic_v1.BaseModel): """ The Product object """ - id: typing.Optional[str] = pydantic.Field(default=None, description="Unique identifier for the Product") - last_published: typing.Optional[dt.datetime] = pydantic.Field( - alias="lastPublished", default=None, description="The date the Product was last published" - ) - last_updated: typing.Optional[dt.datetime] = pydantic.Field( - alias="lastUpdated", default=None, description="The date the Product was last updated" - ) - created_on: typing.Optional[dt.datetime] = pydantic.Field( - alias="createdOn", default=None, description="The date the Product was created" - ) - is_archived: typing.Optional[bool] = pydantic.Field( - alias="isArchived", default=None, description="Boolean determining if the Product is set to archived" - ) - is_draft: typing.Optional[bool] = pydantic.Field( - alias="isDraft", default=None, description="Boolean determining if the Product is set to draft" - ) - field_data: typing.Optional[ProductFieldData] = pydantic.Field(alias="fieldData", default=None) + id: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + Unique identifier for the Product + """ + + cms_locale_id: typing.Optional[str] = pydantic_v1.Field(alias="cmsLocaleId", default=None) + """ + Identifier for the locale of the CMS item + """ + + last_published: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="lastPublished", default=None) + """ + The date the Product was last published + """ + + last_updated: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="lastUpdated", default=None) + """ + The date the Product was last updated + """ + + created_on: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="createdOn", default=None) + """ + The date the Product was created + """ + + is_archived: typing.Optional[bool] = pydantic_v1.Field(alias="isArchived", default=None) + """ + Boolean determining if the Product is set to archived + """ + + is_draft: typing.Optional[bool] = pydantic_v1.Field(alias="isDraft", default=None) + """ + Boolean determining if the Product is set to draft + """ + + field_data: typing.Optional[ProductFieldData] = pydantic_v1.Field(alias="fieldData", default=None) def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/product_and_sk_us.py b/src/webflow/types/product_and_sk_us.py index 64ee6b5..eb9ab3d 100644 --- a/src/webflow/types/product_and_sk_us.py +++ b/src/webflow/types/product_and_sk_us.py @@ -4,32 +4,36 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .product import Product from .sku import Sku -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class ProductAndSkUs(pydantic.BaseModel): +class ProductAndSkUs(pydantic_v1.BaseModel): """ A product and its SKUs. """ product: typing.Optional[Product] = None - skus: typing.Optional[typing.List[Sku]] = pydantic.Field(default=None, description="A list of SKU Objects") + skus: typing.Optional[typing.List[Sku]] = pydantic_v1.Field(default=None) + """ + A list of SKU Objects + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/product_and_sk_us_list.py b/src/webflow/types/product_and_sk_us_list.py index 0c2eae5..db89130 100644 --- a/src/webflow/types/product_and_sk_us_list.py +++ b/src/webflow/types/product_and_sk_us_list.py @@ -4,24 +4,21 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .pagination import Pagination from .product_and_sk_us import ProductAndSkUs -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class ProductAndSkUsList(pydantic.BaseModel): +class ProductAndSkUsList(pydantic_v1.BaseModel): """ Results from product list """ - items: typing.Optional[typing.List[ProductAndSkUs]] = pydantic.Field( - default=None, - description="List of Item objects within the Collection. Contains product and skus keys for each Item", - ) + items: typing.Optional[typing.List[ProductAndSkUs]] = pydantic_v1.Field(default=None) + """ + List of Item objects within the Collection. Contains product and skus keys for each Item + """ + pagination: typing.Optional[Pagination] = None def json(self, **kwargs: typing.Any) -> str: @@ -29,10 +26,15 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/product_field_data.py b/src/webflow/types/product_field_data.py index 756c629..ac2db70 100644 --- a/src/webflow/types/product_field_data.py +++ b/src/webflow/types/product_field_data.py @@ -4,54 +4,82 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .product_field_data_ec_product_type import ProductFieldDataEcProductType from .product_field_data_tax_category import ProductFieldDataTaxCategory from .sku_property_list import SkuPropertyList -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore +class ProductFieldData(pydantic_v1.BaseModel): + """ + Contains content-specific details for a product, covering both standard (e.g., title, description) and custom fields tailored to the product setup. + """ -class ProductFieldData(pydantic.BaseModel): - name: str = pydantic.Field(description="Name of the Product") - slug: str = pydantic.Field(description="URL structure of the Product in your site.") - description: typing.Optional[str] = pydantic.Field(default=None, description="A description of your product") - shippable: typing.Optional[bool] = pydantic.Field( - default=None, description="Boolean determining if the Product is shippable" - ) - sku_properties: typing.Optional[typing.List[SkuPropertyList]] = pydantic.Field( - alias="sku-properties", default=None, description="Variant types to include in SKUs" - ) - categories: typing.Optional[typing.List[str]] = pydantic.Field( - default=None, description="The categories your product belongs to." - ) - tax_category: typing.Optional[ProductFieldDataTaxCategory] = pydantic.Field( - alias="tax-category", default=None, description="Product tax class" - ) - default_sku: typing.Optional[str] = pydantic.Field( - alias="default-sku", default=None, description="The default SKU associated with this product." - ) - ec_product_type: typing.Optional[ProductFieldDataEcProductType] = pydantic.Field( - alias="ec-product-type", - default=None, - description='Product types. Enums reflect the following values in order: Physical, Digital, Service, Advanced"', + name: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + Name of the Product + """ + + slug: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + URL structure of the Product in your site. + """ + + description: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + A description of your product + """ + + shippable: typing.Optional[bool] = pydantic_v1.Field(default=None) + """ + Boolean determining if the Product is shippable + """ + + sku_properties: typing.Optional[typing.List[SkuPropertyList]] = pydantic_v1.Field( + alias="sku-properties", default=None ) - additional_properties: typing.Optional[str] = pydantic.Field( - alias="additionalProperties", default=None, description="Custom fields for your product." + """ + Variant types to include in SKUs + """ + + categories: typing.Optional[typing.List[str]] = pydantic_v1.Field(default=None) + """ + The categories your product belongs to. + """ + + tax_category: typing.Optional[ProductFieldDataTaxCategory] = pydantic_v1.Field(alias="tax-category", default=None) + """ + Product tax class + """ + + default_sku: typing.Optional[str] = pydantic_v1.Field(alias="default-sku", default=None) + """ + The default SKU associated with this product. + """ + + ec_product_type: typing.Optional[ProductFieldDataEcProductType] = pydantic_v1.Field( + alias="ec-product-type", default=None ) + """ + Product types. Enums reflect the following values in order: Physical, Digital, Service, Advanced" + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/registered_script_list.py b/src/webflow/types/registered_script_list.py index 96bcbaa..6ed8db3 100644 --- a/src/webflow/types/registered_script_list.py +++ b/src/webflow/types/registered_script_list.py @@ -4,16 +4,16 @@ import typing from ..core.datetime_utils import serialize_datetime -from .custom_code_response import CustomCodeResponse +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from .custom_code_hosted_response import CustomCodeHostedResponse -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore +class RegisteredScriptList(pydantic_v1.BaseModel): + """ + A list of scripts registered to the site + """ -class RegisteredScriptList(pydantic.BaseModel): - registered_scripts: typing.Optional[typing.List[CustomCodeResponse]] = pydantic.Field( + registered_scripts: typing.Optional[typing.List[CustomCodeHostedResponse]] = pydantic_v1.Field( alias="registeredScripts", default=None ) @@ -22,11 +22,17 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/script_apply.py b/src/webflow/types/script_apply.py index 2868113..38405ee 100644 --- a/src/webflow/types/script_apply.py +++ b/src/webflow/types/script_apply.py @@ -4,33 +4,45 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .script_apply_location import ScriptApplyLocation -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore +class ScriptApply(pydantic_v1.BaseModel): + id: str = pydantic_v1.Field() + """ + ID of the registered custom code script + """ -class ScriptApply(pydantic.BaseModel): - id: str = pydantic.Field(description="Id of the registered custom code script") - location: ScriptApplyLocation = pydantic.Field( - description="Location of the script, either in the header or footer of the published site" - ) - version: str = pydantic.Field(description="Semantic Version String for the registered script _e.g. 0.0.1_") - attributes: typing.Optional[typing.Dict[str, typing.Any]] = pydantic.Field( - default=None, description="Developer-specified key/value pairs to be applied as attributes to the script" - ) + location: ScriptApplyLocation = pydantic_v1.Field() + """ + Location of the script, either in the header or footer of the published site + """ + + version: str = pydantic_v1.Field() + """ + Semantic Version String for the registered script _e.g. 0.0.1_ + """ + + attributes: typing.Optional[typing.Dict[str, typing.Any]] = pydantic_v1.Field(default=None) + """ + Developer-specified key/value pairs to be applied as attributes to the script + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/script_apply_list.py b/src/webflow/types/script_apply_list.py index 23e7579..46b1a69 100644 --- a/src/webflow/types/script_apply_list.py +++ b/src/webflow/types/script_apply_list.py @@ -4,33 +4,42 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .script_apply import ScriptApply -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore +class ScriptApplyList(pydantic_v1.BaseModel): + scripts: typing.Optional[typing.List[ScriptApply]] = pydantic_v1.Field(default=None) + """ + A list of scripts applied to a Site or a Page + """ -class ScriptApplyList(pydantic.BaseModel): - scripts: typing.Optional[typing.List[ScriptApply]] = None - last_updated: typing.Optional[str] = pydantic.Field( - alias="lastUpdated", default=None, description="Date when the Site's scripts were last updated" - ) - created_on: typing.Optional[str] = pydantic.Field( - alias="createdOn", default=None, description="Date when the Site's scripts were created" - ) + last_updated: typing.Optional[str] = pydantic_v1.Field(alias="lastUpdated", default=None) + """ + Date when the Site's scripts were last updated + """ + + created_on: typing.Optional[str] = pydantic_v1.Field(alias="createdOn", default=None) + """ + Date when the Site's scripts were created + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/site.py b/src/webflow/types/site.py index c1bba38..f00321f 100644 --- a/src/webflow/types/site.py +++ b/src/webflow/types/site.py @@ -4,52 +4,81 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .domain import Domain +from .locales import Locales -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - - -class Site(pydantic.BaseModel): - id: str = pydantic.Field(description="Unique identifier for the Site") - workspace_id: typing.Optional[str] = pydantic.Field( - alias="workspaceId", default=None, description="Unique identifier for the Workspace" - ) - created_on: typing.Optional[dt.datetime] = pydantic.Field( - alias="createdOn", default=None, description="Date the Site was created" - ) - display_name: typing.Optional[str] = pydantic.Field( - alias="displayName", default=None, description="Name given to Site" - ) - short_name: typing.Optional[str] = pydantic.Field( - alias="shortName", default=None, description="Slugified version of name" - ) - last_published: typing.Optional[dt.datetime] = pydantic.Field( - alias="lastPublished", default=None, description="Date the Site was last published" - ) - last_updated: typing.Optional[dt.datetime] = pydantic.Field( - alias="lastUpdated", default=None, description="Date the Site was last updated" - ) - preview_url: typing.Optional[str] = pydantic.Field( - alias="previewUrl", default=None, description="URL of a generated image for the given Site" - ) - time_zone: typing.Optional[str] = pydantic.Field( - alias="timeZone", default=None, description="Site timezone set under Site Settings" - ) - custom_domains: typing.Optional[typing.List[Domain]] = pydantic.Field(alias="customDomains", default=None) + +class Site(pydantic_v1.BaseModel): + id: str = pydantic_v1.Field() + """ + Unique identifier for the Site + """ + + workspace_id: typing.Optional[str] = pydantic_v1.Field(alias="workspaceId", default=None) + """ + Unique identifier for the Workspace + """ + + created_on: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="createdOn", default=None) + """ + Date the Site was created + """ + + display_name: typing.Optional[str] = pydantic_v1.Field(alias="displayName", default=None) + """ + Name given to Site + """ + + short_name: typing.Optional[str] = pydantic_v1.Field(alias="shortName", default=None) + """ + Slugified version of name + """ + + last_published: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="lastPublished", default=None) + """ + Date the Site was last published + """ + + last_updated: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="lastUpdated", default=None) + """ + Date the Site was last updated + """ + + preview_url: typing.Optional[str] = pydantic_v1.Field(alias="previewUrl", default=None) + """ + URL of a generated image for the given Site + """ + + time_zone: typing.Optional[str] = pydantic_v1.Field(alias="timeZone", default=None) + """ + Site timezone set under Site Settings + """ + + parent_folder_id: typing.Optional[str] = pydantic_v1.Field(alias="parentFolderId", default=None) + """ + The ID of the parent folder the Site exists in + """ + + custom_domains: typing.Optional[typing.List[Domain]] = pydantic_v1.Field(alias="customDomains", default=None) + locales: typing.Optional[Locales] = None def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/site_activity_log_item.py b/src/webflow/types/site_activity_log_item.py index f04b804..a23608c 100644 --- a/src/webflow/types/site_activity_log_item.py +++ b/src/webflow/types/site_activity_log_item.py @@ -4,28 +4,24 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .site_activity_log_item_resource_operation import SiteActivityLogItemResourceOperation from .site_activity_log_item_user import SiteActivityLogItemUser -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class SiteActivityLogItem(pydantic.BaseModel): +class SiteActivityLogItem(pydantic_v1.BaseModel): id: typing.Optional[str] = None - created_on: typing.Optional[dt.datetime] = pydantic.Field(alias="createdOn", default=None) - last_updated: typing.Optional[dt.datetime] = pydantic.Field(alias="lastUpdated", default=None) + created_on: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="createdOn", default=None) + last_updated: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="lastUpdated", default=None) event: typing.Optional[str] = None - resource_operation: typing.Optional[SiteActivityLogItemResourceOperation] = pydantic.Field( + resource_operation: typing.Optional[SiteActivityLogItemResourceOperation] = pydantic_v1.Field( alias="resourceOperation", default=None ) user: typing.Optional[SiteActivityLogItemUser] = None - resource_id: typing.Optional[str] = pydantic.Field(alias="resourceId", default=None) - resource_name: typing.Optional[str] = pydantic.Field(alias="resourceName", default=None) - new_value: typing.Optional[str] = pydantic.Field(alias="newValue", default=None) - previous_value: typing.Optional[str] = pydantic.Field(alias="previousValue", default=None) + resource_id: typing.Optional[str] = pydantic_v1.Field(alias="resourceId", default=None) + resource_name: typing.Optional[str] = pydantic_v1.Field(alias="resourceName", default=None) + new_value: typing.Optional[str] = pydantic_v1.Field(alias="newValue", default=None) + previous_value: typing.Optional[str] = pydantic_v1.Field(alias="previousValue", default=None) payload: typing.Optional[typing.Dict[str, typing.Any]] = None def json(self, **kwargs: typing.Any) -> str: @@ -33,11 +29,17 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/site_activity_log_item_user.py b/src/webflow/types/site_activity_log_item_user.py index 66bcfbb..60e7846 100644 --- a/src/webflow/types/site_activity_log_item_user.py +++ b/src/webflow/types/site_activity_log_item_user.py @@ -4,27 +4,29 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class SiteActivityLogItemUser(pydantic.BaseModel): +class SiteActivityLogItemUser(pydantic_v1.BaseModel): id: typing.Optional[str] = None - display_name: typing.Optional[str] = pydantic.Field(alias="displayName", default=None) + display_name: typing.Optional[str] = pydantic_v1.Field(alias="displayName", default=None) def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/site_activity_log_response.py b/src/webflow/types/site_activity_log_response.py index 06a04ab..69bcc31 100644 --- a/src/webflow/types/site_activity_log_response.py +++ b/src/webflow/types/site_activity_log_response.py @@ -4,16 +4,12 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .pagination import Pagination from .site_activity_log_item import SiteActivityLogItem -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class SiteActivityLogResponse(pydantic.BaseModel): +class SiteActivityLogResponse(pydantic_v1.BaseModel): items: typing.Optional[typing.List[SiteActivityLogItem]] = None pagination: typing.Optional[Pagination] = None @@ -22,10 +18,15 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/sites.py b/src/webflow/types/sites.py new file mode 100644 index 0000000..18a9338 --- /dev/null +++ b/src/webflow/types/sites.py @@ -0,0 +1,30 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from .site import Site + + +class Sites(pydantic_v1.BaseModel): + sites: typing.Optional[typing.List[Site]] = None + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) + + class Config: + frozen = True + smart_union = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/sku.py b/src/webflow/types/sku.py index a97ee15..ae2008e 100644 --- a/src/webflow/types/sku.py +++ b/src/webflow/types/sku.py @@ -4,43 +4,58 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .sku_field_data import SkuFieldData -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class Sku(pydantic.BaseModel): +class Sku(pydantic_v1.BaseModel): """ The SKU object """ - id: typing.Optional[str] = pydantic.Field(default=None, description="Unique identifier for the Product") - last_published: typing.Optional[dt.datetime] = pydantic.Field( - alias="lastPublished", default=None, description="The date the Product was last published" - ) - last_updated: typing.Optional[dt.datetime] = pydantic.Field( - alias="lastUpdated", default=None, description="The date the Product was last updated" - ) - created_on: typing.Optional[dt.datetime] = pydantic.Field( - alias="createdOn", default=None, description="The date the Product was created" - ) - field_data: typing.Optional[SkuFieldData] = pydantic.Field( - alias="fieldData", default=None, description="Standard and Custom fields for a SKU" - ) + id: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + Unique identifier for the Product + """ + + cms_locale_id: typing.Optional[str] = pydantic_v1.Field(alias="cmsLocaleId", default=None) + """ + Identifier for the locale of the CMS item + """ + + last_published: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="lastPublished", default=None) + """ + The date the Product was last published + """ + + last_updated: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="lastUpdated", default=None) + """ + The date the Product was last updated + """ + + created_on: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="createdOn", default=None) + """ + The date the Product was created + """ + + field_data: typing.Optional[SkuFieldData] = pydantic_v1.Field(alias="fieldData", default=None) def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/sku_field_data.py b/src/webflow/types/sku_field_data.py index 7143bc3..d90c09d 100644 --- a/src/webflow/types/sku_field_data.py +++ b/src/webflow/types/sku_field_data.py @@ -4,55 +4,74 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .sku_field_data_compare_at_price import SkuFieldDataCompareAtPrice from .sku_field_data_ec_sku_billing_method import SkuFieldDataEcSkuBillingMethod from .sku_field_data_ec_sku_subscription_plan import SkuFieldDataEcSkuSubscriptionPlan from .sku_field_data_price import SkuFieldDataPrice from .sku_value_list import SkuValueList -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class SkuFieldData(pydantic.BaseModel): +class SkuFieldData(pydantic_v1.BaseModel): """ Standard and Custom fields for a SKU """ - sku_values: typing.Optional[SkuValueList] = pydantic.Field(alias="sku-values", default=None) - name: str = pydantic.Field(description="Name of the Product") - slug: str = pydantic.Field(description="URL structure of the Product in your site.") - price: SkuFieldDataPrice = pydantic.Field(description="price of SKU") - compare_at_price: typing.Optional[SkuFieldDataCompareAtPrice] = pydantic.Field( - alias="compare-at-price", default=None, description="comparison price of SKU" + sku_values: typing.Optional[SkuValueList] = pydantic_v1.Field(alias="sku-values", default=None) + name: str = pydantic_v1.Field() + """ + Name of the Product + """ + + slug: str = pydantic_v1.Field() + """ + URL structure of the Product in your site. + """ + + price: SkuFieldDataPrice = pydantic_v1.Field() + """ + price of SKU + """ + + compare_at_price: typing.Optional[SkuFieldDataCompareAtPrice] = pydantic_v1.Field( + alias="compare-at-price", default=None ) - ec_sku_billing_method: typing.Optional[SkuFieldDataEcSkuBillingMethod] = pydantic.Field( + """ + comparison price of SKU + """ + + ec_sku_billing_method: typing.Optional[SkuFieldDataEcSkuBillingMethod] = pydantic_v1.Field( alias="ec-sku-billing-method", default=None ) - ec_sku_subscription_plan: typing.Optional[SkuFieldDataEcSkuSubscriptionPlan] = pydantic.Field( + ec_sku_subscription_plan: typing.Optional[SkuFieldDataEcSkuSubscriptionPlan] = pydantic_v1.Field( alias="ec-sku-subscription-plan", default=None ) - track_inventory: typing.Optional[bool] = pydantic.Field( - alias="track-inventory", - default=None, - description="A boolean indicating whether inventory for this product should be tracked.", - ) - quantity: typing.Optional[float] = pydantic.Field( - default=None, description="Quantity of SKU that will be tracked as items are ordered." - ) + track_inventory: typing.Optional[bool] = pydantic_v1.Field(alias="track-inventory", default=None) + """ + A boolean indicating whether inventory for this product should be tracked. + """ + + quantity: typing.Optional[float] = pydantic_v1.Field(default=None) + """ + Quantity of SKU that will be tracked as items are ordered. + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/sku_field_data_compare_at_price.py b/src/webflow/types/sku_field_data_compare_at_price.py index 6b85f7a..2a72eb0 100644 --- a/src/webflow/types/sku_field_data_compare_at_price.py +++ b/src/webflow/types/sku_field_data_compare_at_price.py @@ -4,30 +4,38 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class SkuFieldDataCompareAtPrice(pydantic.BaseModel): +class SkuFieldDataCompareAtPrice(pydantic_v1.BaseModel): """ comparison price of SKU """ - value: typing.Optional[float] = pydantic.Field(default=None, description="Price of SKU") - unit: typing.Optional[str] = pydantic.Field(default=None, description="Currency of Item") + value: typing.Optional[float] = pydantic_v1.Field(default=None) + """ + Price of SKU + """ + + unit: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + Currency of Item + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/sku_field_data_ec_sku_subscription_plan.py b/src/webflow/types/sku_field_data_ec_sku_subscription_plan.py index e69bcb4..cc9e529 100644 --- a/src/webflow/types/sku_field_data_ec_sku_subscription_plan.py +++ b/src/webflow/types/sku_field_data_ec_sku_subscription_plan.py @@ -4,30 +4,43 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .sku_field_data_ec_sku_subscription_plan_interval import SkuFieldDataEcSkuSubscriptionPlanInterval +from .sku_field_data_ec_sku_subscription_plan_plans_item import SkuFieldDataEcSkuSubscriptionPlanPlansItem -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore +class SkuFieldDataEcSkuSubscriptionPlan(pydantic_v1.BaseModel): + interval: typing.Optional[SkuFieldDataEcSkuSubscriptionPlanInterval] = pydantic_v1.Field(default=None) + """ + Interval of subscription renewal + """ -class SkuFieldDataEcSkuSubscriptionPlan(pydantic.BaseModel): - interval: typing.Optional[SkuFieldDataEcSkuSubscriptionPlanInterval] = pydantic.Field( - default=None, description="Interval of subscription renewal" - ) - frequency: typing.Optional[float] = pydantic.Field(default=None, description="Frequncy of billing within interval") - trial: typing.Optional[float] = pydantic.Field(default=None, description="Number of days of a trial") + frequency: typing.Optional[float] = pydantic_v1.Field(default=None) + """ + Frequncy of billing within interval + """ + + trial: typing.Optional[float] = pydantic_v1.Field(default=None) + """ + Number of days of a trial + """ + + plans: typing.Optional[typing.List[SkuFieldDataEcSkuSubscriptionPlanPlansItem]] = None def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/sku_field_data_ec_sku_subscription_plan_plans_item.py b/src/webflow/types/sku_field_data_ec_sku_subscription_plan_plans_item.py new file mode 100644 index 0000000..074cc7a --- /dev/null +++ b/src/webflow/types/sku_field_data_ec_sku_subscription_plan_plans_item.py @@ -0,0 +1,43 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from .sku_field_data_ec_sku_subscription_plan_plans_item_status import SkuFieldDataEcSkuSubscriptionPlanPlansItemStatus + + +class SkuFieldDataEcSkuSubscriptionPlanPlansItem(pydantic_v1.BaseModel): + platform: typing.Optional[typing.Literal["stripe"]] = pydantic_v1.Field(default=None) + """ + The platform of the subscription plan + """ + + id: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + The unique identifier of the plan + """ + + status: typing.Optional[SkuFieldDataEcSkuSubscriptionPlanPlansItemStatus] = pydantic_v1.Field(default=None) + """ + The status of the plan + """ + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) + + class Config: + frozen = True + smart_union = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/sku_field_data_ec_sku_subscription_plan_plans_item_status.py b/src/webflow/types/sku_field_data_ec_sku_subscription_plan_plans_item_status.py new file mode 100644 index 0000000..d5daba6 --- /dev/null +++ b/src/webflow/types/sku_field_data_ec_sku_subscription_plan_plans_item_status.py @@ -0,0 +1,29 @@ +# This file was auto-generated by Fern from our API Definition. + +import enum +import typing + +T_Result = typing.TypeVar("T_Result") + + +class SkuFieldDataEcSkuSubscriptionPlanPlansItemStatus(str, enum.Enum): + """ + The status of the plan + """ + + ACTIVE = "active" + INACTIVE = "inactive" + CANCELED = "canceled" + + def visit( + self, + active: typing.Callable[[], T_Result], + inactive: typing.Callable[[], T_Result], + canceled: typing.Callable[[], T_Result], + ) -> T_Result: + if self is SkuFieldDataEcSkuSubscriptionPlanPlansItemStatus.ACTIVE: + return active() + if self is SkuFieldDataEcSkuSubscriptionPlanPlansItemStatus.INACTIVE: + return inactive() + if self is SkuFieldDataEcSkuSubscriptionPlanPlansItemStatus.CANCELED: + return canceled() diff --git a/src/webflow/types/sku_field_data_price.py b/src/webflow/types/sku_field_data_price.py index a588035..e72419b 100644 --- a/src/webflow/types/sku_field_data_price.py +++ b/src/webflow/types/sku_field_data_price.py @@ -4,30 +4,38 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class SkuFieldDataPrice(pydantic.BaseModel): +class SkuFieldDataPrice(pydantic_v1.BaseModel): """ price of SKU """ - value: typing.Optional[float] = pydantic.Field(default=None, description="Price of SKU") - unit: typing.Optional[str] = pydantic.Field(default=None, description="Currency of Item") + value: typing.Optional[float] = pydantic_v1.Field(default=None) + """ + Price of SKU + """ + + unit: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + Currency of Item + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/sku_property_list.py b/src/webflow/types/sku_property_list.py index 68acf4a..85093e9 100644 --- a/src/webflow/types/sku_property_list.py +++ b/src/webflow/types/sku_property_list.py @@ -4,34 +4,44 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .sku_property_list_enum_item import SkuPropertyListEnumItem -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class SkuPropertyList(pydantic.BaseModel): +class SkuPropertyList(pydantic_v1.BaseModel): """ A variant/option type for a SKU """ - id: str = pydantic.Field(description="Unique identifier for a collection of Product Variants") - name: str = pydantic.Field(description="Name of the collection of Product Variants") - enum: typing.List[SkuPropertyListEnumItem] = pydantic.Field( - description="The individual Product variants that are contained within the collection" - ) + id: str = pydantic_v1.Field() + """ + Unique identifier for a collection of Product Variants + """ + + name: str = pydantic_v1.Field() + """ + Name of the collection of Product Variants + """ + + enum: typing.List[SkuPropertyListEnumItem] = pydantic_v1.Field() + """ + The individual Product variants that are contained within the collection + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/sku_property_list_enum_item.py b/src/webflow/types/sku_property_list_enum_item.py index e995e4a..6a26009 100644 --- a/src/webflow/types/sku_property_list_enum_item.py +++ b/src/webflow/types/sku_property_list_enum_item.py @@ -4,31 +4,43 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class SkuPropertyListEnumItem(pydantic.BaseModel): +class SkuPropertyListEnumItem(pydantic_v1.BaseModel): """ Enumerated Product variants/Options for the SKU """ - id: str = pydantic.Field(description="Unique identifier for a Product variant/Option") - name: str = pydantic.Field(description="Name of the Product variant/Option") - slug: str = pydantic.Field(description="Slug for the Product variant/Option in the Site URL structure") + id: str = pydantic_v1.Field() + """ + Unique identifier for a Product variant/Option + """ + + name: str = pydantic_v1.Field() + """ + Name of the Product variant/Option + """ + + slug: str = pydantic_v1.Field() + """ + Slug for the Product variant/Option in the Site URL structure + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/stripe_card.py b/src/webflow/types/stripe_card.py index deb17d0..a6ba3f2 100644 --- a/src/webflow/types/stripe_card.py +++ b/src/webflow/types/stripe_card.py @@ -4,43 +4,52 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .stripe_card_brand import StripeCardBrand from .stripe_card_expires import StripeCardExpires -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class StripeCard(pydantic.BaseModel): +class StripeCard(pydantic_v1.BaseModel): """ Details on the card used to fulfill this order, if this order was finalized with Stripe. """ - last_4: typing.Optional[str] = pydantic.Field( - alias="last4", default=None, description="The last 4 digits on the card as a string" - ) - brand: typing.Optional[StripeCardBrand] = pydantic.Field( - default=None, description="The card's brand (ie. credit card network)" - ) - owner_name: typing.Optional[str] = pydantic.Field( - alias="ownerName", default=None, description="The name on the card." - ) - expires: typing.Optional[StripeCardExpires] = pydantic.Field( - default=None, description="The card's expiration date." - ) + last_4: typing.Optional[str] = pydantic_v1.Field(alias="last4", default=None) + """ + The last 4 digits on the card as a string + """ + + brand: typing.Optional[StripeCardBrand] = pydantic_v1.Field(default=None) + """ + The card's brand (ie. credit card network) + """ + + owner_name: typing.Optional[str] = pydantic_v1.Field(alias="ownerName", default=None) + """ + The name on the card. + """ + + expires: typing.Optional[StripeCardExpires] = pydantic_v1.Field(default=None) + """ + The card's expiration date. + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/stripe_card_expires.py b/src/webflow/types/stripe_card_expires.py index 793f717..b3eb064 100644 --- a/src/webflow/types/stripe_card_expires.py +++ b/src/webflow/types/stripe_card_expires.py @@ -4,30 +4,38 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class StripeCardExpires(pydantic.BaseModel): +class StripeCardExpires(pydantic_v1.BaseModel): """ The card's expiration date. """ - year: typing.Optional[float] = pydantic.Field(default=None, description="Year that the card expires") - month: typing.Optional[float] = pydantic.Field(default=None, description="Month that the card expires") + year: typing.Optional[float] = pydantic_v1.Field(default=None) + """ + Year that the card expires + """ + + month: typing.Optional[float] = pydantic_v1.Field(default=None) + """ + Month that the card expires + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/stripe_details.py b/src/webflow/types/stripe_details.py index e71a90d..3c03e22 100644 --- a/src/webflow/types/stripe_details.py +++ b/src/webflow/types/stripe_details.py @@ -4,53 +4,70 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class StripeDetails(pydantic.BaseModel): +class StripeDetails(pydantic_v1.BaseModel): """ An object with various Stripe IDs, useful for linking into the stripe dashboard. """ - subscription_id: typing.Optional[str] = pydantic.Field( - alias="subscriptionId", default=None, description="Stripe-generated identifier for the Subscription" - ) - payment_method: typing.Optional[str] = pydantic.Field( - alias="paymentMethod", default=None, description="Stripe-generated identifier for the PaymentMethod used" - ) - payment_intent_id: typing.Optional[str] = pydantic.Field( - alias="paymentIntentId", default=None, description="Stripe-generated identifier for the PaymentIntent, or null" - ) - customer_id: typing.Optional[str] = pydantic.Field( - alias="customerId", default=None, description="Stripe-generated customer identifier, or null" - ) - charge_id: typing.Optional[str] = pydantic.Field( - alias="chargeId", default=None, description="Stripe-generated charge identifier, or null" - ) - dispute_id: typing.Optional[str] = pydantic.Field( - alias="disputeId", default=None, description="Stripe-generated dispute identifier, or null" - ) - refund_id: typing.Optional[str] = pydantic.Field( - alias="refundId", default=None, description="Stripe-generated refund identifier, or null" - ) - refund_reason: typing.Optional[str] = pydantic.Field( - alias="refundReason", default=None, description="Stripe-generated refund reason, or null" - ) + subscription_id: typing.Optional[str] = pydantic_v1.Field(alias="subscriptionId", default=None) + """ + Stripe-generated identifier for the Subscription + """ + + payment_method: typing.Optional[str] = pydantic_v1.Field(alias="paymentMethod", default=None) + """ + Stripe-generated identifier for the PaymentMethod used + """ + + payment_intent_id: typing.Optional[str] = pydantic_v1.Field(alias="paymentIntentId", default=None) + """ + Stripe-generated identifier for the PaymentIntent, or null + """ + + customer_id: typing.Optional[str] = pydantic_v1.Field(alias="customerId", default=None) + """ + Stripe-generated customer identifier, or null + """ + + charge_id: typing.Optional[str] = pydantic_v1.Field(alias="chargeId", default=None) + """ + Stripe-generated charge identifier, or null + """ + + dispute_id: typing.Optional[str] = pydantic_v1.Field(alias="disputeId", default=None) + """ + Stripe-generated dispute identifier, or null + """ + + refund_id: typing.Optional[str] = pydantic_v1.Field(alias="refundId", default=None) + """ + Stripe-generated refund identifier, or null + """ + + refund_reason: typing.Optional[str] = pydantic_v1.Field(alias="refundReason", default=None) + """ + Stripe-generated refund reason, or null + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/text_node.py b/src/webflow/types/text_node.py index e0b9aac..a6a7a6d 100644 --- a/src/webflow/types/text_node.py +++ b/src/webflow/types/text_node.py @@ -4,14 +4,10 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class TextNode(pydantic.BaseModel): +class TextNode(pydantic_v1.BaseModel): """ Represents textual content within the DOM. It contains both the raw text and its HTML representation, allowing for flexibility in rendering and processing. Additional attributes can be associated with the text for styling or other purposes. """ @@ -24,10 +20,15 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/user.py b/src/webflow/types/user.py index ec54559..c443c97 100644 --- a/src/webflow/types/user.py +++ b/src/webflow/types/user.py @@ -4,41 +4,59 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .user_access_groups_item import UserAccessGroupsItem from .user_data import UserData from .user_status import UserStatus -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class User(pydantic.BaseModel): +class User(pydantic_v1.BaseModel): """ The fields that define the schema for a given Item are based on the Collection that Item belongs to. Beyond the user defined fields, there are a handful of additional fields that are automatically created for all items """ - id: typing.Optional[str] = pydantic.Field(default=None, description="Unique identifier for the User") - is_email_verified: typing.Optional[bool] = pydantic.Field( - alias="isEmailVerified", default=None, description="Shows whether the user has verified their email address" - ) - last_updated: typing.Optional[dt.datetime] = pydantic.Field( - alias="lastUpdated", default=None, description="The timestamp the user was updated" - ) - invited_on: typing.Optional[dt.datetime] = pydantic.Field( - alias="invitedOn", default=None, description="The timestamp the user was invited" - ) - created_on: typing.Optional[dt.datetime] = pydantic.Field( - alias="createdOn", default=None, description="The timestamp the user was created" - ) - last_login: typing.Optional[dt.datetime] = pydantic.Field( - alias="lastLogin", default=None, description="The timestamp the user was logged in" - ) - status: typing.Optional[UserStatus] = pydantic.Field(default=None, description="The status of the user") - access_groups: typing.Optional[typing.List[UserAccessGroupsItem]] = pydantic.Field( - alias="accessGroups", default=None, description="Access groups the user belongs to" + id: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + Unique identifier for the User + """ + + is_email_verified: typing.Optional[bool] = pydantic_v1.Field(alias="isEmailVerified", default=None) + """ + Shows whether the user has verified their email address + """ + + last_updated: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="lastUpdated", default=None) + """ + The timestamp the user was updated + """ + + invited_on: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="invitedOn", default=None) + """ + The timestamp the user was invited + """ + + created_on: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="createdOn", default=None) + """ + The timestamp the user was created + """ + + last_login: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="lastLogin", default=None) + """ + The timestamp the user was logged in + """ + + status: typing.Optional[UserStatus] = pydantic_v1.Field(default=None) + """ + The status of the user + """ + + access_groups: typing.Optional[typing.List[UserAccessGroupsItem]] = pydantic_v1.Field( + alias="accessGroups", default=None ) + """ + Access groups the user belongs to + """ + data: typing.Optional[UserData] = None def json(self, **kwargs: typing.Any) -> str: @@ -46,11 +64,17 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/user_access_groups_item.py b/src/webflow/types/user_access_groups_item.py index 7eeb0f7..61aa168 100644 --- a/src/webflow/types/user_access_groups_item.py +++ b/src/webflow/types/user_access_groups_item.py @@ -4,39 +4,42 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .user_access_groups_item_type import UserAccessGroupsItemType -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class UserAccessGroupsItem(pydantic.BaseModel): +class UserAccessGroupsItem(pydantic_v1.BaseModel): """ Access group slugs and types """ - slug: typing.Optional[str] = pydantic.Field(default=None, description="Access group identifier for APIs") - type: typing.Optional[UserAccessGroupsItemType] = pydantic.Field( - default=None, - description=( - "The type of access group based on how it was assigned to the user.\n" - "\n" - "- `admin` - Assigned to the user via API or in the designer\n" - "- `ecommerce` - Assigned to the user via an ecommerce purchase\n" - ), - ) + slug: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + Access group identifier for APIs + """ + + type: typing.Optional[UserAccessGroupsItemType] = pydantic_v1.Field(default=None) + """ + The type of access group based on how it was assigned to the user. + + - `admin` - Assigned to the user via API or in the designer + - `ecommerce` - Assigned to the user via an ecommerce purchase + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/user_data.py b/src/webflow/types/user_data.py index d28d82e..0813b37 100644 --- a/src/webflow/types/user_data.py +++ b/src/webflow/types/user_data.py @@ -4,15 +4,11 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .user_data_data import UserDataData -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class UserData(pydantic.BaseModel): +class UserData(pydantic_v1.BaseModel): """ An object containing the User's basic info and custom fields """ @@ -24,10 +20,15 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/user_data_data.py b/src/webflow/types/user_data_data.py index b58ade7..0366831 100644 --- a/src/webflow/types/user_data_data.py +++ b/src/webflow/types/user_data_data.py @@ -4,40 +4,51 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - - -class UserDataData(pydantic.BaseModel): - name: typing.Optional[str] = pydantic.Field(default=None, description="The name of the user") - email: typing.Optional[str] = pydantic.Field(default=None, description="The email address of the user") - accept_privacy: typing.Optional[bool] = pydantic.Field( - alias="accept-privacy", - default=None, - description="Boolean indicating if the user has accepted the privacy policy", - ) - accept_communications: typing.Optional[bool] = pydantic.Field( - alias="accept-communications", - default=None, - description="Boolean indicating if the user has accepted to receive communications", - ) - additional_properties: typing.Optional[str] = pydantic.Field( - alias="additionalProperties", default=None, description="Custom user attributes" - ) + +class UserDataData(pydantic_v1.BaseModel): + name: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + The name of the user + """ + + email: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + The email address of the user + """ + + accept_privacy: typing.Optional[bool] = pydantic_v1.Field(alias="accept-privacy", default=None) + """ + Boolean indicating if the user has accepted the privacy policy + """ + + accept_communications: typing.Optional[bool] = pydantic_v1.Field(alias="accept-communications", default=None) + """ + Boolean indicating if the user has accepted to receive communications + """ + + additional_properties: typing.Optional[str] = pydantic_v1.Field(alias="additionalProperties", default=None) + """ + Custom user attributes + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/user_limit_reached.py b/src/webflow/types/user_limit_reached.py index e5685fe..62b0412 100644 --- a/src/webflow/types/user_limit_reached.py +++ b/src/webflow/types/user_limit_reached.py @@ -1,37 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing +from .error import Error -from ..core.datetime_utils import serialize_datetime -from .error_details_item import ErrorDetailsItem - -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - - -class UserLimitReached(pydantic.BaseModel): - code: typing.Optional[str] = pydantic.Field(default=None, description="Error code") - message: typing.Optional[str] = pydantic.Field(default=None, description="Error message") - external_reference: typing.Optional[str] = pydantic.Field( - alias="externalReference", default=None, description="Link to more information" - ) - details: typing.Optional[typing.List[ErrorDetailsItem]] = pydantic.Field( - default=None, description="Array of errors" - ) - - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) - - class Config: - frozen = True - smart_union = True - allow_population_by_field_name = True - json_encoders = {dt.datetime: serialize_datetime} +UserLimitReached = Error diff --git a/src/webflow/types/user_list.py b/src/webflow/types/user_list.py index 5c2b5a2..ff1732d 100644 --- a/src/webflow/types/user_list.py +++ b/src/webflow/types/user_list.py @@ -4,34 +4,54 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .user import User -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class UserList(pydantic.BaseModel): +class UserList(pydantic_v1.BaseModel): """ The list users results """ - count: typing.Optional[float] = pydantic.Field(default=None, description="Number of users returned") - limit: typing.Optional[float] = pydantic.Field(default=None, description="The limit specified in the request") - offset: typing.Optional[float] = pydantic.Field(default=None, description="The offset specified for pagination") - total: typing.Optional[float] = pydantic.Field(default=None, description="Total number of users in the collection") - users: typing.Optional[typing.List[User]] = pydantic.Field(default=None, description="List of Users for a Site") + count: typing.Optional[float] = pydantic_v1.Field(default=None) + """ + Number of users returned + """ + + limit: typing.Optional[float] = pydantic_v1.Field(default=None) + """ + The limit specified in the request + """ + + offset: typing.Optional[float] = pydantic_v1.Field(default=None) + """ + The offset specified for pagination + """ + + total: typing.Optional[float] = pydantic_v1.Field(default=None) + """ + Total number of users in the collection + """ + + users: typing.Optional[typing.List[User]] = pydantic_v1.Field(default=None) + """ + List of Users for a Site + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/users_not_enabled.py b/src/webflow/types/users_not_enabled.py index c2959c6..2d9b8d6 100644 --- a/src/webflow/types/users_not_enabled.py +++ b/src/webflow/types/users_not_enabled.py @@ -1,37 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing +from .error import Error -from ..core.datetime_utils import serialize_datetime -from .error_details_item import ErrorDetailsItem - -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - - -class UsersNotEnabled(pydantic.BaseModel): - code: typing.Optional[str] = pydantic.Field(default=None, description="Error code") - message: typing.Optional[str] = pydantic.Field(default=None, description="Error message") - external_reference: typing.Optional[str] = pydantic.Field( - alias="externalReference", default=None, description="Link to more information" - ) - details: typing.Optional[typing.List[ErrorDetailsItem]] = pydantic.Field( - default=None, description="Array of errors" - ) - - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) - - class Config: - frozen = True - smart_union = True - allow_population_by_field_name = True - json_encoders = {dt.datetime: serialize_datetime} +UsersNotEnabled = Error diff --git a/src/webflow/types/webhook.py b/src/webflow/types/webhook.py index 29dff3c..9697dfb 100644 --- a/src/webflow/types/webhook.py +++ b/src/webflow/types/webhook.py @@ -4,49 +4,63 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .trigger_type import TriggerType -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - - -class Webhook(pydantic.BaseModel): - id: typing.Optional[str] = pydantic.Field( - default=None, description="Unique identifier for the Webhook registration" - ) - workspace_id: typing.Optional[str] = pydantic.Field( - alias="workspaceId", - default=None, - description="Unique identifier for the Workspace the Webhook is registered in", - ) - site_id: typing.Optional[str] = pydantic.Field( - alias="siteId", default=None, description="Unique identifier for the Site the Webhook is registered in" - ) - trigger_type: typing.Optional[TriggerType] = pydantic.Field(alias="triggerType", default=None) - filter: typing.Optional[typing.Dict[str, typing.Any]] = pydantic.Field( - default=None, - description="Filter for selecting which events you want Webhooks to be sent for. Only supported for form_submission trigger types.", - ) - last_triggered: typing.Optional[dt.datetime] = pydantic.Field( - alias="lastTriggered", default=None, description="Date the Webhook instance was last triggered" - ) - created_on: typing.Optional[dt.datetime] = pydantic.Field( - alias="createdOn", default=None, description="Date the Webhook registration was created" - ) - url: typing.Optional[str] = pydantic.Field(default=None, description="URL to send the Webhook payload to") + +class Webhook(pydantic_v1.BaseModel): + id: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + Unique identifier for the Webhook registration + """ + + workspace_id: typing.Optional[str] = pydantic_v1.Field(alias="workspaceId", default=None) + """ + Unique identifier for the Workspace the Webhook is registered in + """ + + site_id: typing.Optional[str] = pydantic_v1.Field(alias="siteId", default=None) + """ + Unique identifier for the Site the Webhook is registered in + """ + + trigger_type: typing.Optional[TriggerType] = pydantic_v1.Field(alias="triggerType", default=None) + filter: typing.Optional[typing.Dict[str, typing.Any]] = pydantic_v1.Field(default=None) + """ + Filter for selecting which events you want Webhooks to be sent for. Only supported for form_submission trigger types. + """ + + last_triggered: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="lastTriggered", default=None) + """ + Date the Webhook instance was last triggered + """ + + created_on: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="createdOn", default=None) + """ + Date the Webhook registration was created + """ + + url: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + URL to send the Webhook payload to + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/types/webhook_list.py b/src/webflow/types/webhook_list.py index 62f5dd2..d55f417 100644 --- a/src/webflow/types/webhook_list.py +++ b/src/webflow/types/webhook_list.py @@ -4,16 +4,12 @@ import typing from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .pagination import Pagination from .webhook import Webhook -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - -class WebhookList(pydantic.BaseModel): +class WebhookList(pydantic_v1.BaseModel): pagination: typing.Optional[Pagination] = None webhooks: typing.Optional[typing.List[Webhook]] = None @@ -22,10 +18,15 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True + extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/webflow/version.py b/src/webflow/version.py new file mode 100644 index 0000000..c84c3e9 --- /dev/null +++ b/src/webflow/version.py @@ -0,0 +1,4 @@ + +from importlib import metadata + +__version__ = metadata.version("webflow") diff --git a/tests/__init__.py b/tests/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/tests/test_client.py b/tests/custom/test_client.py similarity index 100% rename from tests/test_client.py rename to tests/custom/test_client.py diff --git a/tests/utils/test_http_client.py b/tests/utils/test_http_client.py new file mode 100644 index 0000000..98fd3c9 --- /dev/null +++ b/tests/utils/test_http_client.py @@ -0,0 +1,47 @@ +# This file was auto-generated by Fern from our API Definition. + +from webflow.core.http_client import get_request_body +from webflow.core.request_options import RequestOptions + + +def get_request_options() -> RequestOptions: + return {"additional_body_parameters": {"see you": "later"}} + + +def test_get_json_request_body() -> None: + json_body, data_body = get_request_body(json={"hello": "world"}, data=None, request_options=None, omit=None) + assert json_body == {"hello": "world"} + assert data_body is None + + json_body_extras, data_body_extras = get_request_body( + json={"goodbye": "world"}, data=None, request_options=get_request_options(), omit=None + ) + + assert json_body_extras == {"goodbye": "world", "see you": "later"} + assert data_body_extras is None + + +def test_get_files_request_body() -> None: + json_body, data_body = get_request_body(json=None, data={"hello": "world"}, request_options=None, omit=None) + assert data_body == {"hello": "world"} + assert json_body is None + + json_body_extras, data_body_extras = get_request_body( + json=None, data={"goodbye": "world"}, request_options=get_request_options(), omit=None + ) + + assert data_body_extras == {"goodbye": "world", "see you": "later"} + assert json_body_extras is None + + +def test_get_none_request_body() -> None: + json_body, data_body = get_request_body(json=None, data=None, request_options=None, omit=None) + assert data_body is None + assert json_body is None + + json_body_extras, data_body_extras = get_request_body( + json=None, data=None, request_options=get_request_options(), omit=None + ) + + assert json_body_extras == {"see you": "later"} + assert data_body_extras is None diff --git a/tests/utils/test_query_encoding.py b/tests/utils/test_query_encoding.py new file mode 100644 index 0000000..a5d083e --- /dev/null +++ b/tests/utils/test_query_encoding.py @@ -0,0 +1,13 @@ +# This file was auto-generated by Fern from our API Definition. + +from webflow.core.query_encoder import encode_query + + +def test_query_encoding() -> None: + assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} + assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { + "hello_world[hello][world]": "today", + "hello_world[test]": "this", + "hi": "there", + }