Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
)
prices.append(price)
schema = schemas.PriceSchema()
for variant in get_product_variants(target_obj):
if variant["sku"] == action.sku:
variant["prices"] = schema.dump(prices, many=True)
if action.staged:
new["masterData"]["hasStagedChanges"] = True
return new
return updater
class UploadImageQuerySchema(Schema):
staged = schema_fields.Bool()
filename = schema_fields.Field()
sku = schema_fields.Field()
class ProductsBackend(ServiceBackend):
service_path = "products"
model_class = ProductsModel
_schema_draft = schemas.ProductDraftSchema
_schema_update = schemas.ProductUpdateSchema
_schema_query_response = schemas.ProductPagedQueryResponseSchema
def urls(self):
return [
("^$", "GET", self.query),
("^$", "POST", self.create),
("^key=(?P[^/]+)$", "GET", self.get_by_key),
"""
super(Ping, self).__init__(**kwargs)
self.comment = comment
self.response_requested = response_requested
class PingSchema(AgentMessageSchema):
"""Schema for Ping class."""
class Meta:
"""PingSchema metadata."""
model_class = Ping
response_requested = fields.Bool(default=True, required=False)
comment = fields.Str(required=False, allow_none=True)
networks = marshmallow.fields.List(
marshmallow.fields.Nested(PlatformsDockerNetworksSchema))
dns_servers = marshmallow.fields.List(marshmallow.fields.Str())
class PlatformsVagrantSchema(PlatformsBaseSchema):
box = marshmallow.fields.Str()
box_version = marshmallow.fields.Str()
box_url = marshmallow.fields.Str()
memory = marshmallow.fields.Int()
cpus = marshmallow.fields.Int()
raw_config_args = marshmallow.fields.List(marshmallow.fields.Str())
interfaces = marshmallow.fields.List(
marshmallow.fields.Nested(InterfaceSchema()))
provider = marshmallow.fields.Str()
force_stop = marshmallow.fields.Bool()
class ProvisionerInventoryLinksSchema(base.BaseUnknown):
host_vars = marshmallow.fields.Str()
group_vars = marshmallow.fields.Str()
class ProvisionerInventorySchema(base.BaseUnknown):
host_vars = marshmallow.fields.Dict()
group_vars = marshmallow.fields.Dict()
links = marshmallow.fields.Nested(ProvisionerInventoryLinksSchema())
class PlaybooksSchema(base.BaseUnknown):
create = marshmallow.fields.Str()
converge = marshmallow.fields.Str()
'my_bookings': fields.Bool(missing=False),
'limit': fields.Int(missing=40),
'text': fields.String(missing=None)
})
def _process(self, room_ids, start_dt, last_reservation_id, my_bookings, limit, text):
start_dt = start_dt or datetime.combine(date.today(), time(0, 0))
booked_for_user = session.user if my_bookings else None
bookings, rows_left = get_active_bookings(limit=limit,
start_dt=start_dt,
last_reservation_id=last_reservation_id,
room_ids=room_ids,
booked_for_user=booked_for_user,
text=text)
return jsonify(bookings=serialize_occurrences(bookings), rows_left=rows_left)
modified_at = fields.DateTime(data_key="modifiedAt")
modified_by = fields.Field(data_key="modifiedBy") # TODO: User object
num = fields.Int(data_key="rowNumber")
permalink = fields.Str()
version = fields.Int()
cells = fields.List(fields.Nested(CellSchema))
columns = fields.List(fields.Nested(ColumnSchema))
# location-specifier attributes
parent_id = fields.Int(data_key="parentId")
sibling_id = fields.Int(data_key="siblingId")
above = fields.Bool()
indent = fields.Int()
outdent = fields.Int()
to_bottom = fields.Bool(data_key="toBottom")
to_top = fields.Bool(data_key="toTop")
CellT = TypeVar("CellT", bound=Cell)
RowT = TypeVar("RowT", bound="_RowBase[Any]")
ColumnT = TypeVar("ColumnT", bound=Column)
@attr.s(auto_attribs=True, repr=False, kw_only=True)
class _RowBase(Object, Generic[CellT]):
id: Optional[int] = None
sheet_id: Optional[int] = None
access_level: Optional[str] = None
attachments: List[Any] = attr.Factory(list)
conditional_format: Optional[str] = None
created_at: Optional[datetime] = None
class EnvironmentSchema(BaseSchema):
resources = fields.Nested(ResourceRequirementsSchema, allow_none=True)
labels = fields.Dict(values=fields.Str(), keys=fields.Str(), allow_none=True)
annotations = fields.Dict(values=fields.Str(), keys=fields.Str(), allow_none=True)
node_selector = fields.Dict(values=fields.Str(), keys=fields.Str(), allow_none=True)
affinity = fields.Dict(allow_none=True)
tolerations = fields.List(fields.Dict(), allow_none=True)
service_account = fields.Str(allow_none=True)
image_pull_secrets = fields.List(fields.Str(), allow_none=True)
env_vars = fields.Dict(values=fields.Str(), keys=fields.Str(), allow_none=True)
security_context = fields.Dict(allow_none=True)
log_level = fields.Str(allow_none=True)
auth = fields.Bool(allow_none=True)
docker = fields.Bool(allow_none=True)
shm = fields.Bool(allow_none=True)
outputs = fields.Bool(allow_none=True)
logs = fields.Bool(allow_none=True)
registry = fields.Str(allow_none=True)
init_container = fields.Nested(ContainerEnvSchema, allow_none=True)
sidecar_container = fields.Nested(ContainerEnvSchema, allow_none=True)
@staticmethod
def schema_config():
return EnvironmentConfig
class EnvironmentConfig(BaseConfig, V1Environment):
"""
Pod environment config.
"""
IDENTIFIER = "environment"
from typing import List, Optional
from marshmallow import fields
from commercetools import schemas, types
from commercetools.services import abstract
from commercetools.typing import OptionalListStr
class ShoppingListDeleteSchema(abstract.AbstractDeleteSchema):
data_erasure = fields.Bool(data_key="dataErasure", required=False)
class ShoppingListQuerySchema(abstract.AbstractQuerySchema):
pass
class ShoppingListService(abstract.AbstractService):
def get_by_id(self, id: str) -> types.ShoppingList:
return self._client._get(f"shopping-lists/{id}", {}, schemas.ShoppingListSchema)
def get_by_key(self, key: str) -> types.ShoppingList:
return self._client._get(
f"shopping-lists/key={key}", {}, schemas.ShoppingListSchema
)
def query(
"Marshmallow schema for :class:`commercetools.types.CustomerSignin`."
email = marshmallow.fields.String(allow_none=True)
password = marshmallow.fields.String(allow_none=True)
anonymous_cart_id = marshmallow.fields.String(
allow_none=True, missing=None, data_key="anonymousCartId"
)
anonymous_cart_sign_in_mode = marshmallow_enum.EnumField(
types.AnonymousCartSignInMode,
by_value=True,
missing=None,
data_key="anonymousCartSignInMode",
)
anonymous_id = marshmallow.fields.String(
allow_none=True, missing=None, data_key="anonymousId"
)
update_product_data = marshmallow.fields.Bool(
allow_none=True, missing=None, data_key="updateProductData"
)
class Meta:
unknown = marshmallow.EXCLUDE
@marshmallow.post_load
def post_load(self, data, **kwargs):
return types.CustomerSignin(**data)
class CustomerTokenSchema(marshmallow.Schema):
"Marshmallow schema for :class:`commercetools.types.CustomerToken`."
id = marshmallow.fields.String(allow_none=True)
created_at = marshmallow.fields.DateTime(allow_none=True, data_key="createdAt")
last_modified_at = marshmallow.fields.DateTime(
UseDevelopmentAPNS = fields.Boolean(attribute='use_development_apns')
@post_load
def make_payload(self, data: dict) -> models.MDMPayload:
return models.MDMPayload(**data)
class ProfileSchema(Schema):
PayloadDescription = fields.Str(attribute='description')
PayloadDisplayName = fields.Str(attribute='display_name')
PayloadExpirationDate = fields.DateTime(attribute='expiration_date')
PayloadIdentifier = fields.Str(attribute='identifier', required=True)
PayloadOrganization = fields.Str(attribute='organization')
PayloadUUID = fields.UUID(attribute='uuid')
PayloadRemovalDisallowed = fields.Bool(attribute='removal_disallowed')
PayloadType = fields.Function(lambda obj: 'Configuration', attribute='payload_type')
PayloadVersion = fields.Function(lambda obj: 1, attribute='version')
PayloadScope = EnumField(PayloadScope, attribute='scope')
RemovalDate = fields.DateTime(attribute='removal_date')
DurationUntilRemoval = fields.Float(attribute='duration_until_removal')
ConsentText = fields.Nested(ConsentTextSchema())
PayloadContent = fields.Method('get_payloads', deserialize='load_payloads')
def get_payloads(self, obj):
payloads = []
for payload in obj.payloads:
schema = schema_for(payload.type)
if schema is not None:
result = schema().dump(payload)
payloads.append(result.data)
from marshmallow import Schema, fields, missing
class MoveSchema(Schema):
number = fields.Int()
guess = fields.Str()
bulls = fields.Function(lambda move: move.bulls())
cows = fields.Function(lambda move: move.cows())
class GameSchema(Schema):
id = fields.Int()
bet = fields.Int()
has_ended = fields.Bool()
secret_number = fields.Function(lambda game: game.secret_number if game.has_ended else missing)
moves = fields.Nested(MoveSchema, many=True)
class UserSchema(Schema):
balance = fields.Int()
codes = fields.Function(lambda obj: obj.codes())
games = fields.Nested(GameSchema, many=True)