Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

codegen output f8257545d18743caae2c369bcb69def9 #42

Merged
merged 9 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:
USER_ID: ${{ secrets.USER_ID }}
ENTERPRISE_ID: ${{ secrets.ENTERPRISE_ID }}
BOX_FILE_REQUEST_ID: ${{ secrets.BOX_FILE_REQUEST_ID }}
BOX_EXTERNAL_USER_EMAIL: ${{ secrets.BOX_EXTERNAL_USER_EMAIL }}
run: |
tox

Expand Down Expand Up @@ -69,3 +70,4 @@ jobs:
USER_ID: ${{ secrets.USER_ID }}
ENTERPRISE_ID: ${{ secrets.ENTERPRISE_ID }}
BOX_FILE_REQUEST_ID: ${{ secrets.BOX_FILE_REQUEST_ID }}
BOX_EXTERNAL_USER_EMAIL: ${{ secrets.BOX_EXTERNAL_USER_EMAIL }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Now select `Authorization` and submit application to be reviewed by account admi
download your app configuration settings as JSON.
2. Encode configuration file to Base64, e.g. using command: `base64 -i path_to_json_file`
3. Set environment variable: `JWT_CONFIG_BASE_64` with base64 encoded jwt configuration file
4. Set environment variable: `BOX_FILE_REQUEST_ID` with ID of file request already created in the user account.
4. Set environment variable: `BOX_FILE_REQUEST_ID` with ID of file request already created in the user account, `BOX_EXTERNAL_USER_EMAIL` with email of free external user which not belongs to any enterprise.

### Running tests

Expand Down
2 changes: 1 addition & 1 deletion box_sdk_gen/auth_schemas.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from enum import Enum
from typing import Union, List
from typing import Union

from .base_object import BaseObject

Expand Down
12 changes: 8 additions & 4 deletions box_sdk_gen/base_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,17 @@ def _deserialize_list(cls, key, value, annotation: list):
@classmethod
def _deserialize_union(cls, key, value, annotation):
possible_types = get_args(annotation)
if value is None:
if type(None) not in possible_types:
print('Value: ', value, 'should not be allowed in Union:', annotation)
return value
if 'type' in value:
type_field = 'type'
else:
type_field = 'skillCardType'
type_field_value = value.get(type_field, None)

type = None
curr_type = None
for i, possible_type in enumerate(possible_types):
try:
if (
Expand All @@ -91,16 +95,16 @@ def _deserialize_union(cls, key, value, annotation):
type_field_value.upper()
]
):
type = possible_types[i]
curr_type = possible_types[i]
break
except Exception:
continue

if not type:
if not curr_type:
print('Could not deserialize Union: ', annotation, 'of value:', value)

try:
return cls._deserialize(key, value, type)
return cls._deserialize(key, value, curr_type)
except Exception:
return value

Expand Down
2 changes: 0 additions & 2 deletions box_sdk_gen/ccg_auth.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import json
from urllib.parse import urlencode
from typing import Union, Optional

from .auth import Authentication
Expand Down
7 changes: 6 additions & 1 deletion box_sdk_gen/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@
from .network import NetworkSession
from .auth import Authentication
from .utils import ByteStream, ResponseByteStream
from .json import SerializedData, sd_to_json, sd_to_url_params, json_to_serialized_data
from .json_data import (
SerializedData,
sd_to_json,
sd_to_url_params,
json_to_serialized_data,
)

DEFAULT_MAX_ATTEMPTS = 5
_RETRY_RANDOMIZATION_FACTOR = 0.5
Expand Down
5 changes: 2 additions & 3 deletions box_sdk_gen/json.py → box_sdk_gen/json_data.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import json
from typing import Dict
from urllib.parse import urlencode


class SerializedData:
pass
SerializedData = Dict


def json_to_serialized_data(data: str) -> SerializedData:
Expand Down
3 changes: 1 addition & 2 deletions box_sdk_gen/jwt_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import string

from typing import Optional, Any
from urllib.parse import urlencode

try:
import jwt
Expand All @@ -22,7 +21,7 @@
from .fetch import fetch, FetchResponse, FetchOptions
from .network import NetworkSession
from .schemas import AccessToken
from .json import json_to_serialized_data
from .json_data import json_to_serialized_data


class JWTConfig:
Expand Down
2 changes: 1 addition & 1 deletion box_sdk_gen/managers/authorization.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

from box_sdk_gen.utils import ByteStream

from box_sdk_gen.json import sd_to_json
from box_sdk_gen.json_data import sd_to_json

from box_sdk_gen.fetch import fetch

Expand Down
4 changes: 2 additions & 2 deletions box_sdk_gen/managers/avatars.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@

from box_sdk_gen.fetch import FetchResponse

from box_sdk_gen.json import sd_to_json
from box_sdk_gen.json_data import sd_to_json

from box_sdk_gen.fetch import MultipartItem

from box_sdk_gen.json import SerializedData
from box_sdk_gen.json_data import SerializedData


class AvatarsManager:
Expand Down
4 changes: 2 additions & 2 deletions box_sdk_gen/managers/chunked_uploads.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@

from box_sdk_gen.fetch import FetchResponse

from box_sdk_gen.json import SerializedData
from box_sdk_gen.json_data import SerializedData

from box_sdk_gen.json import sd_to_json
from box_sdk_gen.json_data import sd_to_json

from box_sdk_gen.utils import generate_byte_stream_from_buffer

Expand Down
Loading
Loading