_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q224900 | CosmosClient.UpsertStoredProcedure | train | def UpsertStoredProcedure(self, collection_link, sproc, options=None):
"""Upserts a stored procedure in a collection.
:param str collection_link:
The link to the document collection.
:param str sproc:
:param dict options:
The request options for the request.
... | python | {
"resource": ""
} |
q224901 | CosmosClient.ReadStoredProcedure | train | def ReadStoredProcedure(self, sproc_link, options=None):
"""Reads a stored procedure.
:param str sproc_link:
The link to the stored procedure.
:param dict options:
The request options for the request.
:return:
The read Stored Procedure.
:rtyp... | python | {
"resource": ""
} |
q224902 | CosmosClient.ReadConflicts | train | def ReadConflicts(self, collection_link, feed_options=None):
"""Reads conflicts.
:param str collection_link:
The link to the document collection.
:param dict feed_options:
:return:
Query Iterable of Conflicts.
:rtype:
query_iterable.QueryIter... | python | {
"resource": ""
} |
q224903 | CosmosClient.ReadConflict | train | def ReadConflict(self, conflict_link, options=None):
"""Reads a conflict.
:param str conflict_link:
The link to the conflict.
:param dict options:
:return:
The read Conflict.
:rtype:
dict
"""
if options is None:
o... | python | {
"resource": ""
} |
q224904 | CosmosClient.DeleteContainer | train | def DeleteContainer(self, collection_link, options=None):
"""Deletes a collection.
:param str collection_link:
The link to the document collection.
:param dict options:
The request options for the request.
:return:
The deleted Collection.
:rt... | python | {
"resource": ""
} |
q224905 | CosmosClient.ReplaceItem | train | def ReplaceItem(self, document_link, new_document, options=None):
"""Replaces a document and returns it.
:param str document_link:
The link to the document.
:param dict new_document:
:param dict options:
The request options for the request.
:return:
... | python | {
"resource": ""
} |
q224906 | CosmosClient.CreateAttachment | train | def CreateAttachment(self, document_link, attachment, options=None):
"""Creates an attachment in a document.
:param str document_link:
The link to the document.
:param dict attachment:
The Azure Cosmos attachment to create.
:param dict options:
The re... | python | {
"resource": ""
} |
q224907 | CosmosClient.UpsertAttachment | train | def UpsertAttachment(self, document_link, attachment, options=None):
"""Upserts an attachment in a document.
:param str document_link:
The link to the document.
:param dict attachment:
The Azure Cosmos attachment to upsert.
:param dict options:
The re... | python | {
"resource": ""
} |
q224908 | CosmosClient.CreateAttachmentAndUploadMedia | train | def CreateAttachmentAndUploadMedia(self,
document_link,
readable_stream,
options=None):
"""Creates an attachment and upload media.
:param str document_link:
The link to the d... | python | {
"resource": ""
} |
q224909 | CosmosClient.UpsertAttachmentAndUploadMedia | train | def UpsertAttachmentAndUploadMedia(self,
document_link,
readable_stream,
options=None):
"""Upserts an attachment and upload media.
:param str document_link:
The link to the d... | python | {
"resource": ""
} |
q224910 | CosmosClient.ReadAttachment | train | def ReadAttachment(self, attachment_link, options=None):
"""Reads an attachment.
:param str attachment_link:
The link to the attachment.
:param dict options:
The request options for the request.
:return:
The read Attachment.
:rtype:
... | python | {
"resource": ""
} |
q224911 | CosmosClient.ReadAttachments | train | def ReadAttachments(self, document_link, options=None):
"""Reads all attachments in a document.
:param str document_link:
The link to the document.
:param dict options:
The request options for the request.
:return:
Query Iterable of Attachments.
... | python | {
"resource": ""
} |
q224912 | CosmosClient.QueryAttachments | train | def QueryAttachments(self, document_link, query, options=None):
"""Queries attachments in a document.
:param str document_link:
The link to the document.
:param (str or dict) query:
:param dict options:
The request options for the request.
:return:
... | python | {
"resource": ""
} |
q224913 | CosmosClient.ReadMedia | train | def ReadMedia(self, media_link):
"""Reads a media.
When self.connection_policy.MediaReadMode ==
documents.MediaReadMode.Streamed, returns a file-like stream object;
otherwise, returns a str.
:param str media_link:
The link to the media.
:return:
... | python | {
"resource": ""
} |
q224914 | CosmosClient.UpdateMedia | train | def UpdateMedia(self, media_link, readable_stream, options=None):
"""Updates a media and returns it.
:param str media_link:
The link to the media.
:param (file-like stream object) readable_stream:
:param dict options:
The request options for the request.
... | python | {
"resource": ""
} |
q224915 | CosmosClient.ReplaceAttachment | train | def ReplaceAttachment(self, attachment_link, attachment, options=None):
"""Replaces an attachment and returns it.
:param str attachment_link:
The link to the attachment.
:param dict attachment:
:param dict options:
The request options for the request.
:r... | python | {
"resource": ""
} |
q224916 | CosmosClient.DeleteAttachment | train | def DeleteAttachment(self, attachment_link, options=None):
"""Deletes an attachment.
:param str attachment_link:
The link to the attachment.
:param dict options:
The request options for the request.
:return:
The deleted Attachment.
:rtype:
... | python | {
"resource": ""
} |
q224917 | CosmosClient.ReplaceTrigger | train | def ReplaceTrigger(self, trigger_link, trigger, options=None):
"""Replaces a trigger and returns it.
:param str trigger_link:
The link to the trigger.
:param dict trigger:
:param dict options:
The request options for the request.
:return:
The... | python | {
"resource": ""
} |
q224918 | CosmosClient.DeleteTrigger | train | def DeleteTrigger(self, trigger_link, options=None):
"""Deletes a trigger.
:param str trigger_link:
The link to the trigger.
:param dict options:
The request options for the request.
:return:
The deleted Trigger.
:rtype:
dict
... | python | {
"resource": ""
} |
q224919 | CosmosClient.ReplaceUserDefinedFunction | train | def ReplaceUserDefinedFunction(self, udf_link, udf, options=None):
"""Replaces a user defined function and returns it.
:param str udf_link:
The link to the user defined function.
:param dict udf:
:param dict options:
The request options for the request.
... | python | {
"resource": ""
} |
q224920 | CosmosClient.DeleteUserDefinedFunction | train | def DeleteUserDefinedFunction(self, udf_link, options=None):
"""Deletes a user defined function.
:param str udf_link:
The link to the user defined function.
:param dict options:
The request options for the request.
:return:
The deleted UDF.
:... | python | {
"resource": ""
} |
q224921 | CosmosClient.ExecuteStoredProcedure | train | def ExecuteStoredProcedure(self, sproc_link, params, options=None):
"""Executes a store procedure.
:param str sproc_link:
The link to the stored procedure.
:param dict params:
List or None
:param dict options:
The request options for the request.
... | python | {
"resource": ""
} |
q224922 | CosmosClient.ReplaceStoredProcedure | train | def ReplaceStoredProcedure(self, sproc_link, sproc, options=None):
"""Replaces a stored procedure and returns it.
:param str sproc_link:
The link to the stored procedure.
:param dict sproc:
:param dict options:
The request options for the request.
:retur... | python | {
"resource": ""
} |
q224923 | CosmosClient.DeleteStoredProcedure | train | def DeleteStoredProcedure(self, sproc_link, options=None):
"""Deletes a stored procedure.
:param str sproc_link:
The link to the stored procedure.
:param dict options:
The request options for the request.
:return:
The deleted Stored Procedure.
... | python | {
"resource": ""
} |
q224924 | CosmosClient.DeleteConflict | train | def DeleteConflict(self, conflict_link, options=None):
"""Deletes a conflict.
:param str conflict_link:
The link to the conflict.
:param dict options:
The request options for the request.
:return:
The deleted Conflict.
:rtype:
dic... | python | {
"resource": ""
} |
q224925 | CosmosClient.ReplaceOffer | train | def ReplaceOffer(self, offer_link, offer):
"""Replaces an offer and returns it.
:param str offer_link:
The link to the offer.
:param dict offer:
:return:
The replaced Offer.
:rtype:
dict
"""
CosmosClient.__ValidateResource(of... | python | {
"resource": ""
} |
q224926 | CosmosClient.ReadOffer | train | def ReadOffer(self, offer_link):
"""Reads an offer.
:param str offer_link:
The link to the offer.
:return:
The read Offer.
:rtype:
dict
"""
path = base.GetPathFromLink(offer_link)
offer_id = base.GetResourceIdOrFullNameFromLi... | python | {
"resource": ""
} |
q224927 | CosmosClient.GetDatabaseAccount | train | def GetDatabaseAccount(self, url_connection=None):
"""Gets database account info.
:return:
The Database Account.
:rtype:
documents.DatabaseAccount
"""
if url_connection is None:
url_connection = self.url_connection
initial_headers = ... | python | {
"resource": ""
} |
q224928 | CosmosClient.Create | train | def Create(self, body, path, type, id, initial_headers, options=None):
"""Creates a Azure Cosmos resource and returns it.
:param dict body:
:param str path:
:param str type:
:param str id:
:param dict initial_headers:
:param dict options:
The request ... | python | {
"resource": ""
} |
q224929 | CosmosClient.Replace | train | def Replace(self, resource, path, type, id, initial_headers, options=None):
"""Replaces a Azure Cosmos resource and returns it.
:param dict resource:
:param str path:
:param str type:
:param str id:
:param dict initial_headers:
:param dict options:
Th... | python | {
"resource": ""
} |
q224930 | CosmosClient.Read | train | def Read(self, path, type, id, initial_headers, options=None):
"""Reads a Azure Cosmos resource and returns it.
:param str path:
:param str type:
:param str id:
:param dict initial_headers:
:param dict options:
The request options for the request.
:r... | python | {
"resource": ""
} |
q224931 | CosmosClient.DeleteResource | train | def DeleteResource(self, path, type, id, initial_headers, options=None):
"""Deletes a Azure Cosmos resource and returns it.
:param str path:
:param str type:
:param str id:
:param dict initial_headers:
:param dict options:
The request options for the request.... | python | {
"resource": ""
} |
q224932 | CosmosClient.__Get | train | def __Get(self, path, request, headers):
"""Azure Cosmos 'GET' http request.
:params str url:
:params str path:
:params dict headers:
:return:
Tuple of (result, headers).
:rtype:
tuple of (dict, dict)
"""
return synchronized_requ... | python | {
"resource": ""
} |
q224933 | CosmosClient.__Post | train | def __Post(self, path, request, body, headers):
"""Azure Cosmos 'POST' http request.
:params str url:
:params str path:
:params (str, unicode, dict) body:
:params dict headers:
:return:
Tuple of (result, headers).
:rtype:
tuple of (dict, ... | python | {
"resource": ""
} |
q224934 | CosmosClient.__Delete | train | def __Delete(self, path, request, headers):
"""Azure Cosmos 'DELETE' http request.
:params str url:
:params str path:
:params dict headers:
:return:
Tuple of (result, headers).
:rtype:
tuple of (dict, dict)
"""
return synchronize... | python | {
"resource": ""
} |
q224935 | CosmosClient.QueryFeed | train | def QueryFeed(self, path, collection_id, query, options, partition_key_range_id = None):
"""Query Feed for Document Collection resource.
:param str path:
Path to the document collection.
:param str collection_id:
Id of the document collection.
:param (str or dict... | python | {
"resource": ""
} |
q224936 | CosmosClient.__QueryFeed | train | def __QueryFeed(self,
path,
type,
id,
result_fn,
create_fn,
query,
options=None,
partition_key_range_id=None):
"""Query for more than one Azure Cosmos r... | python | {
"resource": ""
} |
q224937 | CosmosClient.__CheckAndUnifyQueryFormat | train | def __CheckAndUnifyQueryFormat(self, query_body):
"""Checks and unifies the format of the query body.
:raises TypeError: If query_body is not of expected type (depending on the query compatibility mode).
:raises ValueError: If query_body is a dict but doesn\'t have valid query text.
:ra... | python | {
"resource": ""
} |
q224938 | CosmosClient._UpdateSessionIfRequired | train | def _UpdateSessionIfRequired(self, request_headers, response_result, response_headers):
"""
Updates session if necessary.
:param dict response_result:
:param dict response_headers:
:param dict response_headers
:return:
None, but updates the client sessio... | python | {
"resource": ""
} |
q224939 | GetResourceIdOrFullNameFromLink | train | def GetResourceIdOrFullNameFromLink(resource_link):
"""Gets resource id or full name from resource link.
:param str resource_link:
:return:
The resource id or full name from the resource link.
:rtype: str
"""
# For named based, the resource link is the full name
if IsNameBased(reso... | python | {
"resource": ""
} |
q224940 | GetAttachmentIdFromMediaId | train | def GetAttachmentIdFromMediaId(media_id):
"""Gets attachment id from media id.
:param str media_id:
:return:
The attachment id from the media id.
:rtype: str
"""
altchars = '+-'
if not six.PY2:
altchars = altchars.encode('utf-8')
# altchars for '+' and '/'. We keep '+' ... | python | {
"resource": ""
} |
q224941 | GetPathFromLink | train | def GetPathFromLink(resource_link, resource_type=''):
"""Gets path from resource link with optional resource type
:param str resource_link:
:param str resource_type:
:return:
Path from resource link with resource type appended (if provided).
:rtype: str
"""
resource_link = TrimBegi... | python | {
"resource": ""
} |
q224942 | IsNameBased | train | def IsNameBased(link):
"""Finds whether the link is name based or not
:param str link:
:return:
True if link is name-based; otherwise, False.
:rtype: boolean
"""
if not link:
return False
# trimming the leading "/"
if link.startswith('/') and len(link) > 1:
lin... | python | {
"resource": ""
} |
q224943 | IsDatabaseLink | train | def IsDatabaseLink(link):
"""Finds whether the link is a database Self Link or a database ID based link
:param str link:
Link to analyze
:return:
True or False.
:rtype: boolean
"""
if not link:
return False
# trimming the leading and trailing "/" from the input str... | python | {
"resource": ""
} |
q224944 | GetItemContainerInfo | train | def GetItemContainerInfo(self_link, alt_content_path, id_from_response):
""" Given the self link and alt_content_path from the reponse header and result
extract the collection name and collection id
Ever response header has alt-content-path that is the
owner's path in ascii. For document c... | python | {
"resource": ""
} |
q224945 | GetItemContainerLink | train | def GetItemContainerLink(link):
"""Gets the document collection link
:param str link:
Resource link
:return:
Document collection link.
:rtype: str
"""
link = TrimBeginningAndEndingSlashes(link) + '/'
index = IndexOfNth(link, '/', 4)
if index != -1:
return... | python | {
"resource": ""
} |
q224946 | IndexOfNth | train | def IndexOfNth(s, value, n):
"""Gets the index of Nth occurance of a given character in a string
:param str s:
Input string
:param char value:
Input char to be searched.
:param int n:
Nth occurrence of char to be searched.
:return:
Index of the Nth occurrence in the... | python | {
"resource": ""
} |
q224947 | TrimBeginningAndEndingSlashes | train | def TrimBeginningAndEndingSlashes(path):
"""Trims beginning and ending slashes
:param str path:
:return:
Path with beginning and ending slashes trimmed.
:rtype: str
"""
if path.startswith('/'):
# Returns substring starting from index 1 to end of the string
path = path[1... | python | {
"resource": ""
} |
q224948 | _RequestBodyFromData | train | def _RequestBodyFromData(data):
"""Gets request body from data.
When `data` is dict and list into unicode string; otherwise return `data`
without making any change.
:param (str, unicode, file-like stream object, dict, list or None) data:
:rtype:
str, unicode, file-like stream object, or N... | python | {
"resource": ""
} |
q224949 | _Request | train | def _Request(global_endpoint_manager, request, connection_policy, requests_session, path, request_options, request_body):
"""Makes one http request using the requests module.
:param _GlobalEndpointManager global_endpoint_manager:
:param dict request:
contains the resourceType, operationType, endpoi... | python | {
"resource": ""
} |
q224950 | SynchronizedRequest | train | def SynchronizedRequest(client,
request,
global_endpoint_manager,
connection_policy,
requests_session,
method,
path,
request_data,
... | python | {
"resource": ""
} |
q224951 | _CollectionRoutingMap.get_range_by_effective_partition_key | train | def get_range_by_effective_partition_key(self, effective_partition_key_value):
"""Gets the range containing the given partition key
:param str effective_partition_key_value:
The partition key value.
:return:
The partition key range.
:rtype: dict
"""
... | python | {
"resource": ""
} |
q224952 | _CollectionRoutingMap.get_range_by_partition_key_range_id | train | def get_range_by_partition_key_range_id(self, partition_key_range_id):
"""Gets the partition key range given the partition key range id
:param str partition_key_range_id:
The partition key range id.
:return:
The partition key range.
:rtype: dict
"""
... | python | {
"resource": ""
} |
q224953 | _CollectionRoutingMap.get_overlapping_ranges | train | def get_overlapping_ranges(self, provided_partition_key_ranges):
"""Gets the partition key ranges overlapping the provided ranges
:param list provided_partition_key_ranges:
List of partition key ranges.
:return:
List of partition key ranges, where each is a dict.
... | python | {
"resource": ""
} |
q224954 | GetAuthorizationHeader | train | def GetAuthorizationHeader(cosmos_client,
verb,
path,
resource_id_or_fullname,
is_name_based,
resource_type,
headers):
"""Gets the authorization header.
... | python | {
"resource": ""
} |
q224955 | __GetAuthorizationTokenUsingMasterKey | train | def __GetAuthorizationTokenUsingMasterKey(verb,
resource_id_or_fullname,
resource_type,
headers,
master_key):
"""Gets the authorization token using `mas... | python | {
"resource": ""
} |
q224956 | __GetAuthorizationTokenUsingResourceTokens | train | def __GetAuthorizationTokenUsingResourceTokens(resource_tokens,
path,
resource_id_or_fullname):
"""Get the authorization token using `resource_tokens`.
:param dict resource_tokens:
:param str path:
:param str re... | python | {
"resource": ""
} |
q224957 | SessionContainer.parse_session_token | train | def parse_session_token(response_headers):
""" Extracts session token from response headers and parses
:param dict response_headers:
:return:
A dictionary of partition id to session lsn
for given collection
:rtype: dict
"""
# extract sessio... | python | {
"resource": ""
} |
q224958 | VectorMixin.generate_vector_color_map | train | def generate_vector_color_map(self):
"""Generate color stops array for use with match expression in mapbox template"""
vector_stops = []
# if join data specified as filename or URL, parse JSON to list of Python dicts
if type(self.data) == str:
self.data = geojson_to_dict_lis... | python | {
"resource": ""
} |
q224959 | VectorMixin.generate_vector_numeric_map | train | def generate_vector_numeric_map(self, numeric_property):
"""Generate stops array for use with match expression in mapbox template"""
vector_stops = []
function_type = getattr(self, '{}_function_type'.format(numeric_property))
lookup_property = getattr(self, '{}_property'.format(... | python | {
"resource": ""
} |
q224960 | VectorMixin.check_vector_template | train | def check_vector_template(self):
"""Determines if features are defined as vector source based on MapViz arguments."""
if self.vector_url is not None and self.vector_layer_name is not None:
self.template = 'vector_' + self.template
self.vector_source = True
else:
... | python | {
"resource": ""
} |
q224961 | MapViz.as_iframe | train | def as_iframe(self, html_data):
"""Build the HTML representation for the mapviz."""
srcdoc = html_data.replace('"', "'")
return ('<iframe id="{div_id}", srcdoc="{srcdoc}" style="width: {width}; '
'height: {height};"></iframe>'.format(
div_id=self.div_id,
... | python | {
"resource": ""
} |
q224962 | CircleViz.add_unique_template_variables | train | def add_unique_template_variables(self, options):
"""Update map template variables specific to circle visual"""
options.update(dict(
geojson_data=json.dumps(self.data, ensure_ascii=False),
colorProperty=self.color_property,
colorType=self.color_function_type,
... | python | {
"resource": ""
} |
q224963 | GraduatedCircleViz.add_unique_template_variables | train | def add_unique_template_variables(self, options):
"""Update map template variables specific to graduated circle visual"""
options.update(dict(
colorProperty=self.color_property,
colorStops=self.color_stops,
colorType=self.color_function_type,
radiusType=se... | python | {
"resource": ""
} |
q224964 | ClusteredCircleViz.add_unique_template_variables | train | def add_unique_template_variables(self, options):
"""Update map template variables specific to a clustered circle visual"""
options.update(dict(
colorStops=self.color_stops,
colorDefault=self.color_default,
radiusStops=self.radius_stops,
clusterRadius=self... | python | {
"resource": ""
} |
q224965 | ImageViz.add_unique_template_variables | train | def add_unique_template_variables(self, options):
"""Update map template variables specific to image visual"""
options.update(dict(
image=self.image,
coordinates=self.coordinates)) | python | {
"resource": ""
} |
q224966 | RasterTilesViz.add_unique_template_variables | train | def add_unique_template_variables(self, options):
"""Update map template variables specific to a raster visual"""
options.update(dict(
tiles_url=self.tiles_url,
tiles_size=self.tiles_size,
tiles_minzoom=self.tiles_minzoom,
tiles_maxzoom=self.tiles_maxzoom,... | python | {
"resource": ""
} |
q224967 | LinestringViz.add_unique_template_variables | train | def add_unique_template_variables(self, options):
"""Update map template variables specific to linestring visual"""
# set line stroke dash interval based on line_stroke property
if self.line_stroke in ["dashed", "--"]:
self.line_dash_array = [6, 4]
elif self.line_stroke in [... | python | {
"resource": ""
} |
q224968 | row_to_geojson | train | def row_to_geojson(row, lon, lat, precision, date_format='epoch'):
"""Convert a pandas dataframe row to a geojson format object. Converts all datetimes to epoch seconds.
"""
# Let pandas handle json serialization
row_json = json.loads(row.to_json(date_format=date_format, date_unit='s'))
return geo... | python | {
"resource": ""
} |
q224969 | scale_between | train | def scale_between(minval, maxval, numStops):
""" Scale a min and max value to equal interval domain with
numStops discrete values
"""
scale = []
if numStops < 2:
return [minval, maxval]
elif maxval < minval:
raise ValueError()
else:
domain = maxval - minval
... | python | {
"resource": ""
} |
q224970 | create_radius_stops | train | def create_radius_stops(breaks, min_radius, max_radius):
"""Convert a data breaks into a radius ramp
"""
num_breaks = len(breaks)
radius_breaks = scale_between(min_radius, max_radius, num_breaks)
stops = []
for i, b in enumerate(breaks):
stops.append([b, radius_breaks[i]])
return st... | python | {
"resource": ""
} |
q224971 | create_weight_stops | train | def create_weight_stops(breaks):
"""Convert data breaks into a heatmap-weight ramp
"""
num_breaks = len(breaks)
weight_breaks = scale_between(0, 1, num_breaks)
stops = []
for i, b in enumerate(breaks):
stops.append([b, weight_breaks[i]])
return stops | python | {
"resource": ""
} |
q224972 | create_color_stops | train | def create_color_stops(breaks, colors='RdYlGn', color_ramps=color_ramps):
"""Convert a list of breaks into color stops using colors from colorBrewer
or a custom list of color values in RGB, RGBA, HSL, CSS text, or HEX format.
See www.colorbrewer2.org for a list of color options to pass
"""
num_brea... | python | {
"resource": ""
} |
q224973 | numeric_map | train | def numeric_map(lookup, numeric_stops, default=0.0):
"""Return a number value interpolated from given numeric_stops
"""
# if no numeric_stops, use default
if len(numeric_stops) == 0:
return default
# dictionary to lookup value from match-type numeric_stops
match_map = dict((x, y) fo... | python | {
"resource": ""
} |
q224974 | load_yaml_from_docstring | train | def load_yaml_from_docstring(docstring):
"""Loads YAML from docstring."""
split_lines = trim_docstring(docstring).split("\n")
# Cut YAML from rest of docstring
for index, line in enumerate(split_lines):
line = line.strip()
if line.startswith("---"):
cut_from = index
... | python | {
"resource": ""
} |
q224975 | load_operations_from_docstring | train | def load_operations_from_docstring(docstring):
"""Return a dictionary of OpenAPI operations parsed from a
a docstring.
"""
doc_data = load_yaml_from_docstring(docstring)
return {
key: val
for key, val in iteritems(doc_data)
if key in PATH_KEYS or key.startswith("x-")
} | python | {
"resource": ""
} |
q224976 | get_fields | train | def get_fields(schema, exclude_dump_only=False):
"""Return fields from schema
:param Schema schema: A marshmallow Schema instance or a class object
:param bool exclude_dump_only: whether to filter fields in Meta.dump_only
:rtype: dict, of field name field object pairs
"""
if hasattr(schema, "fi... | python | {
"resource": ""
} |
q224977 | warn_if_fields_defined_in_meta | train | def warn_if_fields_defined_in_meta(fields, Meta):
"""Warns user that fields defined in Meta.fields or Meta.additional will
be ignored
:param dict fields: A dictionary of fields name field object pairs
:param Meta: the schema's Meta class
"""
if getattr(Meta, "fields", None) or getattr(Meta, "ad... | python | {
"resource": ""
} |
q224978 | filter_excluded_fields | train | def filter_excluded_fields(fields, Meta, exclude_dump_only):
"""Filter fields that should be ignored in the OpenAPI spec
:param dict fields: A dictionary of fields name field object pairs
:param Meta: the schema's Meta class
:param bool exclude_dump_only: whether to filter fields in Meta.dump_only
... | python | {
"resource": ""
} |
q224979 | get_unique_schema_name | train | def get_unique_schema_name(components, name, counter=0):
"""Function to generate a unique name based on the provided name and names
already in the spec. Will append a number to the name to make it unique if
the name is already in the spec.
:param Components components: instance of the components of th... | python | {
"resource": ""
} |
q224980 | build_reference | train | def build_reference(component_type, openapi_major_version, component_name):
"""Return path to reference
:param str component_type: Component type (schema, parameter, response, security_scheme)
:param int openapi_major_version: OpenAPI major version (2 or 3)
:param str component_name: Name of component ... | python | {
"resource": ""
} |
q224981 | deepupdate | train | def deepupdate(original, update):
"""Recursively update a dict.
Subdict's won't be overwritten but also updated.
"""
for key, value in original.items():
if key not in update:
update[key] = value
elif isinstance(value, dict):
deepupdate(value, update[key])
ret... | python | {
"resource": ""
} |
q224982 | OpenAPIConverter._observed_name | train | def _observed_name(field, name):
"""Adjust field name to reflect `dump_to` and `load_from` attributes.
:param Field field: A marshmallow field.
:param str name: Field name
:rtype: str
"""
if MARSHMALLOW_VERSION_INFO[0] < 3:
# use getattr in case we're running... | python | {
"resource": ""
} |
q224983 | OpenAPIConverter.map_to_openapi_type | train | def map_to_openapi_type(self, *args):
"""Decorator to set mapping for custom fields.
``*args`` can be:
- a pair of the form ``(type, format)``
- a core marshmallow field type (in which case we reuse that type's mapping)
"""
if len(args) == 1 and args[0] in self.field_ma... | python | {
"resource": ""
} |
q224984 | OpenAPIConverter.field2type_and_format | train | def field2type_and_format(self, field):
"""Return the dictionary of OpenAPI type and format based on the field
type
:param Field field: A marshmallow field.
:rtype: dict
"""
# If this type isn't directly in the field mapping then check the
# hierarchy until we fi... | python | {
"resource": ""
} |
q224985 | OpenAPIConverter.field2default | train | def field2default(self, field):
"""Return the dictionary containing the field's default value
Will first look for a `doc_default` key in the field's metadata and then
fall back on the field's `missing` parameter. A callable passed to the
field's missing parameter will be ignored.
... | python | {
"resource": ""
} |
q224986 | OpenAPIConverter.field2choices | train | def field2choices(self, field, **kwargs):
"""Return the dictionary of OpenAPI field attributes for valid choices definition
:param Field field: A marshmallow field.
:rtype: dict
"""
attributes = {}
comparable = [
validator.comparable
for validato... | python | {
"resource": ""
} |
q224987 | OpenAPIConverter.field2read_only | train | def field2read_only(self, field, **kwargs):
"""Return the dictionary of OpenAPI field attributes for a dump_only field.
:param Field field: A marshmallow field.
:rtype: dict
"""
attributes = {}
if field.dump_only:
attributes["readOnly"] = True
return ... | python | {
"resource": ""
} |
q224988 | OpenAPIConverter.field2write_only | train | def field2write_only(self, field, **kwargs):
"""Return the dictionary of OpenAPI field attributes for a load_only field.
:param Field field: A marshmallow field.
:rtype: dict
"""
attributes = {}
if field.load_only and self.openapi_version.major >= 3:
attribut... | python | {
"resource": ""
} |
q224989 | OpenAPIConverter.field2nullable | train | def field2nullable(self, field, **kwargs):
"""Return the dictionary of OpenAPI field attributes for a nullable field.
:param Field field: A marshmallow field.
:rtype: dict
"""
attributes = {}
if field.allow_none:
attributes[
"x-nullable" if se... | python | {
"resource": ""
} |
q224990 | OpenAPIConverter.metadata2properties | train | def metadata2properties(self, field):
"""Return a dictionary of properties extracted from field Metadata
Will include field metadata that are valid properties of `OpenAPI schema
objects
<https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#schemaObject>`_
(... | python | {
"resource": ""
} |
q224991 | OpenAPIConverter.resolve_nested_schema | train | def resolve_nested_schema(self, schema):
"""Return the Open API representation of a marshmallow Schema.
Adds the schema to the spec if it isn't already present.
Typically will return a dictionary with the reference to the schema's
path in the spec unless the `schema_name_resolver` retu... | python | {
"resource": ""
} |
q224992 | OpenAPIConverter.property2parameter | train | def property2parameter(
self,
prop,
name="body",
required=False,
multiple=False,
location=None,
default_in="body",
):
"""Return the Parameter Object definition for a JSON Schema property.
https://github.com/OAI/OpenAPI-Specification/blob/maste... | python | {
"resource": ""
} |
q224993 | OpenAPIConverter.get_ref_dict | train | def get_ref_dict(self, schema):
"""Method to create a dictionary containing a JSON reference to the
schema in the spec
"""
schema_key = make_schema_key(schema)
ref_schema = build_reference(
"schema", self.openapi_version.major, self.refs[schema_key]
)
... | python | {
"resource": ""
} |
q224994 | clean_operations | train | def clean_operations(operations, openapi_major_version):
"""Ensure that all parameters with "in" equal to "path" are also required
as required by the OpenAPI specification, as well as normalizing any
references to global parameters. Also checks for invalid HTTP methods.
See https://github.com/OAI/OpenA... | python | {
"resource": ""
} |
q224995 | Components.schema | train | def schema(self, name, component=None, **kwargs):
"""Add a new schema to the spec.
:param str name: identifier by which schema may be referenced.
:param dict component: schema definition.
.. note::
If you are using `apispec.ext.marshmallow`, you can pass fields' metadata a... | python | {
"resource": ""
} |
q224996 | Components.parameter | train | def parameter(self, component_id, location, component=None, **kwargs):
""" Add a parameter which can be referenced.
:param str param_id: identifier by which parameter may be referenced.
:param str location: location of the parameter.
:param dict component: parameter fields.
:par... | python | {
"resource": ""
} |
q224997 | Components.response | train | def response(self, component_id, component=None, **kwargs):
"""Add a response which can be referenced.
:param str component_id: ref_id to use as reference
:param dict component: response fields
:param dict kwargs: plugin-specific arguments
"""
if component_id in self._re... | python | {
"resource": ""
} |
q224998 | Components.security_scheme | train | def security_scheme(self, component_id, component):
"""Add a security scheme which can be referenced.
:param str component_id: component_id to use as reference
:param dict kwargs: security scheme fields
"""
if component_id in self._security_schemes:
raise DuplicateCo... | python | {
"resource": ""
} |
q224999 | APISpec.path | train | def path(
self, path=None, operations=None, summary=None, description=None, **kwargs
):
"""Add a new path object to the spec.
https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#path-item-object
:param str|None path: URL path component
:param dict|Non... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.