How to use the marshmallow.fields.Str function in marshmallow

To help you get started, we’ve selected a few marshmallow examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github polyaxon / polyaxon / cli / polyaxon / schemas / cli / client_configuration.py View on Github external
timeout = fields.Float(allow_none=True, data_key=POLYAXON_KEYS_TIMEOUT)
    watch_interval = fields.Int(allow_none=True, data_key=POLYAXON_KEYS_WATCH_INTERVAL)
    interval = fields.Float(allow_none=True, data_key=POLYAXON_KEYS_INTERVAL)
    verify_ssl = fields.Bool(allow_none=True, data_key=POLYAXON_KEYS_VERIFY_SSL)
    ssl_ca_cert = fields.Str(allow_none=True, data_key=POLYAXON_KEYS_SSL_CA_CERT)
    cert_file = fields.Str(allow_none=True, data_key=POLYAXON_KEYS_CERT_FILE)
    key_file = fields.Str(allow_none=True, data_key=POLYAXON_KEYS_KEY_FILE)
    assert_hostname = fields.Bool(
        allow_none=True, data_key=POLYAXON_KEYS_ASSERT_HOSTNAME
    )
    connection_pool_maxsize = fields.Int(
        allow_none=True, data_key=POLYAXON_KEYS_CONNECTION_POOL_MAXSIZE
    )

    header = fields.Str(allow_none=True, data_key=POLYAXON_KEYS_HEADER)
    header_service = fields.Str(allow_none=True, data_key=POLYAXON_KEYS_HEADER_SERVICE)

    pod_id = fields.Str(allow_none=True, data_key=POLYAXON_KEYS_K8S_POD_ID)
    namespace = fields.Str(allow_none=True, data_key=POLYAXON_KEYS_K8S_NAMESPACE)

    @staticmethod
    def schema_config():
        return ClientConfig


class ClientConfig(BaseConfig):
    SCHEMA = ClientSchema
    IDENTIFIER = "global"

    PAGE_SIZE = 20
    BASE_URL = "{}/api/{}"
github Netflix / repokid / repokid / cli / dispatcher_cli.py View on Github external
self.respond_channel = respond_channel
        self.respond_user = respond_user
        self.requestor = requestor
        self.reason = reason
        self.selection = selection


class MessageSchema(Schema):
    command = fields.Str(required=True)
    account = fields.Str(required=True)
    role_name = fields.Str(required=True)
    respond_channel = fields.Str(required=True)
    respond_user = fields.Str()
    requestor = fields.Str()
    reason = fields.Str()
    selection = fields.Str()

    @post_load
    def make_message(self, data):
        return Message(**data)


def get_failure_message(channel=None, message=None):
    return {"channel": channel, "message": message, "title": "Repokid Failure"}


@sts_conn("sqs")
def delete_message(receipt_handle, client=None):
    client.delete_message(
        QueueUrl=CONFIG["dispatcher"]["to_rr_queue"], ReceiptHandle=receipt_handle
    )
github bharadwajyarlagadda / bingmaps / bingmaps / urls / traffic_build_urls.py View on Github external
max=4,
            error='All the four coordinates should be entered: south latitude,'
                  'west longitude, north latitude and east longitude in the '
                  'same order'
        )
    )
    includeLocationCodes = fields.Str(
        default='false'
    )
    severity = fields.List(
        fields.Int
    )
    type = fields.List(
        fields.Int
    )
    o = fields.Str()
    key = fields.Str(
        required=True,
        error_messages={'required': 'Bing Maps API key required'}
    )

    class Meta:
        fields = ('version', 'restApi', 'resourcePath', 'mapArea',
                  'includeLocationCodes', 'severity', 'type', 'o', 'key')
        ordered = True

    @post_dump
    def build_url(self, data):
        """This method occurs after dumping the data into the class.

        Args:
            data (dict): dictionary of all the query values
github ansible / molecule / molecule / model / schema.py View on Github external
lint = marshmallow.fields.Nested(LintSchema())


class ScenarioSchema(base.BaseUnknown):
    name = marshmallow.fields.Str()
    check_sequence = marshmallow.fields.List(marshmallow.fields.Str())
    converge_sequence = marshmallow.fields.List(marshmallow.fields.Str())
    create_sequence = marshmallow.fields.List(marshmallow.fields.Str())
    destroy_sequence = marshmallow.fields.List(marshmallow.fields.Str())
    test_sequence = marshmallow.fields.List(marshmallow.fields.Str())


class VerifierSchema(base.BaseUnknown):
    name = marshmallow.fields.Str()
    enabled = marshmallow.fields.Bool()
    directory = marshmallow.fields.Str()
    options = marshmallow.fields.Dict()
    env = marshmallow.fields.Dict()
    additional_files_or_dirs = marshmallow.fields.List(
        marshmallow.fields.Str())
    lint = marshmallow.fields.Nested(LintSchema())


class MoleculeBaseSchema(base.BaseUnknown):
    dependency = marshmallow.fields.Nested(DependencySchema())
    driver = marshmallow.fields.Nested(DriverSchema())
    lint = marshmallow.fields.Nested(LintSchema())
    provisioner = marshmallow.fields.Nested(ProvisionerSchema())
    scenario = marshmallow.fields.Nested(ScenarioSchema())
    verifier = marshmallow.fields.Nested(VerifierSchema())
github datashaman / wifidog-auth-flask / app / users / models.py View on Github external
return '' % self.email

    def to_dict(self):
        return { c.name: getattr(self, c.name) for c in self.__table__.columns }

@login_manager.user_loader
def load_user(id):
    return User.query.get(id)

datastore = SQLAlchemyUserDatastore(db, User, Role)
security = Security(app, datastore)

class UserSchema(Schema):
    id = fields.Int()
    email = fields.Str()
    password = fields.Str()
    network_id = fields.Str()
    gateway_id = fields.Str()
    created_at = fields.DateTime()

    def make_object(self, data):
        return User(**data)

def filter_many(search_params=None, **kwargs):
    if search_params is None:
        search_params = {}

    if 'filters' not in search_params:
        search_params['filters'] = []

    if current_user.has_role('network-admin'):
        search_params['filters'].append(dict(name='network_id', op='eq', val=current_user.network_id))
github polyaxon / polyaxon / polyaxon_schemas / ml / processing / image.py View on Github external
**kwargs
    ):
        super(ExtractGlimpseConfig, self).__init__(**kwargs)
        self.size = size
        self.offsets = offsets
        self.centered = centered
        self.normalized = normalized
        self.uniform_noise = uniform_noise


class ToBoundingBoxSchema(BaseLayerSchema):
    offset_height = fields.Int(validate=lambda n: n >= 0)
    offset_width = fields.Int(validate=lambda n: n >= 0)
    target_height = fields.Int(validate=lambda n: n >= 0)
    target_width = fields.Int(validate=lambda n: n >= 0)
    method = fields.Str(allow_none=True, validate=validate.OneOf(["crop", "pad"]))
    name = fields.Str(allow_none=True)

    @staticmethod
    def schema_config():
        return ToBoundingBoxConfig


class ToBoundingBoxConfig(BaseLayerConfig):
    """Pad/Crop `image` with zeros to the specified `height` and `width`.
    (A mirror to tf.image pad_to_bounding_box and crop_to_bounding_box)

    If method == 'pad':
        Adds `offset_height` rows of zeros on top, `offset_width` columns of
        zeros on the left, and then pads the image on the bottom and right
        with zeros until it has dimensions `target_height`, `target_width`.
github cmdmnt / commandment / commandment / profiles / plist_schema.py View on Github external
@register_payload_schema('Profile Service')
class ProfileServicePayload(Schema):
    URL = fields.URL()
    DeviceAttributes = fields.String(many=True)
    Challenge = fields.String()
    

class ConsentTextSchema(Schema):
    en = fields.String(attribute='consent_en')


@register_payload_schema('com.apple.security.pem', 'com.apple.security.root', 'com.apple.security.pkcs1',
                         'com.apple.security.pkcs12')
class CertificatePayloadSchema(Payload):
    PayloadCertificateFileName = fields.Str(attribute='certificate_file_name')
    PayloadContent = fields.Raw(attribute='payload_content')
    Password = fields.Str(attribute='password')



@register_payload_schema('com.apple.security.scep')
class SCEPPayload(Payload):
    URL = fields.URL(attribute='url')
    Name = fields.String(attribute='name')
    # Subject = fields.Nested()
    Challenge = fields.String(attribute='challenge')
    Keysize = fields.Integer(attribute='key_size')
    CAFingerprint = fields.String(attribute='ca_fingerprint')
    KeyType = fields.String(attribute='key_type')
    KeyUsage = EnumField(KeyUsage, attribute='key_usage', by_value=True)
    # SubjectAltName = fields.Dict(attribute='subject_alt_name')
github cloudblue / connect-python-sdk / connect / models / schemas.py View on Github external
from connect.models import UsageListing
        return UsageListing(**data)


class UsageRecordSchema(BaseSchema):
    usage_record_id = fields.Str()
    usage_record_note = fields.Str()
    item_search_criteria = fields.Str()
    item_search_value = fields.Str()
    amount = fields.Int()
    quantity = fields.Int()
    start_time_utc = fields.Str()
    end_time_utc = fields.Str()
    asset_search_criteria = fields.Str()
    asset_search_value = fields.Str()
    item_name = fields.Str()
    item_npm = fields.Str()
    item_unit = fields.Str()
    item_precision = fields.Str()
    category_id = fields.Str()
    asset_recon_id = fields.Str()
    tier = fields.Str()

    @post_load
    def make_object(self, data):
        from connect.models import UsageRecord
        return UsageRecord(**data)


class ConversationMessageSchema(BaseSchema):
    conversation = fields.Str()
    created = fields.DateTime()
github teliportme / remixvr / backend / remixvr / activity / serializers.py View on Github external
from marshmallow import Schema, fields, pre_load, post_dump

from remixvr.activitytype.serializers import ActivityTypeSchema
from remixvr.classroom.serializers import ClassroomSchema


class ActivitySchema(Schema):
    id = fields.Int()
    activity_name = fields.Str()
    activity_type = fields.Nested(ActivityTypeSchema, only=[
                                  'pdf_link', 'slug', 'title', 'id'])
    activity_type_id = fields.Int(load_only=True)
    classroom = fields.Nested(ClassroomSchema, only=[
                              'classname', 'slug', 'school'])
    classroom_slug = fields.Str(load_only=True)
    code = fields.Str(dump_only=True)
    is_reaction = fields.Bool()
    submissions_count = fields.Int()
    reaction_to_id = fields.Int(load_only=True)
    reaction_to = fields.Nested('self', only=['code', 'classroom.school'])
    reactions = fields.Nested('self', default=None, many=True)
    created_at = fields.DateTime()
    updated_at = fields.DateTime(dump_only=True)

    class Meta:
        strict = True


class ActivitySchemas(ActivitySchema):

    @post_dump(pass_many=True)
    def dump_activities(self, data, many):
github hypothesis / lms / lms / validation / _canvas.py View on Github external
return [
            {"id": enrollment["course_section_id"]}
            for enrollment in data["enrollments"]
        ]


class CanvasListFilesResponseSchema(RequestsResponseSchema):
    """
    Schema for the Canvas API's list_files responses.

    https://canvas.instructure.com/doc/api/files.html#method.files.api_index
    """

    many = True

    display_name = fields.Str(required=True)
    id = fields.Integer(required=True)
    updated_at = fields.String(required=True)


class CanvasPublicURLResponseSchema(RequestsResponseSchema):
    """
    Schema for the Canvas API's public_url responses.

    https://canvas.instructure.com/doc/api/files.html#method.files.public_url
    """

    public_url = fields.Str(required=True)