Creates a PageBlobService object with the settings specified in the 
        CloudStorageAccount.

        :return: A service object.
        :rtype: :class:`~azure.storage.blob.pageblobservice.PageBlobService`
485132
def create_page_blob_service(self):
        '''
        
        '''
        try:
            from azure.storage.blob.pageblobservice import PageBlobService
            return PageBlobService(self.account_name, self.account_key,
                                   sas_token=self.sas_token,
                                   is_emulated=self.is_emulated)
        except ImportError:
            raise Exception('The package azure-storage-blob is required. '
                            + 'Please install it using "pip install azure-storage-blob"')
734258
def cache_page(**kwargs):
    
    cache_timeout = kwargs.pop('cache_timeout', None)
    key_prefix = kwargs.pop('key_prefix', None)
    cache_min_age = kwargs.pop('cache_min_age', None)
    decorator = decorators.decorator_from_middleware_with_args(CacheMiddleware)(
        cache_timeout=cache_timeout,
        key_prefix=key_prefix,
        cache_min_age=cache_min_age,
        **kwargs
    )
    return decorator
696657
def save(self):
        

        data = {
            'waitForSync': self.waitForSync,
            'journalSize': self.journalSize,
        }

        self.resource(self.name).properties.put(data)
1081009
def get(self, request):
        
        next_page = request.GET.get('next')
        required = request.GET.get('required', False)

        service_url = get_service_url(request, next_page)
        client = get_cas_client(service_url=service_url, request=request)

        if not next_page and settings.CAS_STORE_NEXT and 'CASNEXT' in request.session:
            next_page = request.session['CASNEXT']
            del request.session['CASNEXT']

        if not next_page:
            next_page = get_redirect_url(request)

        if request.user.is_authenticated:
            if settings.CAS_LOGGED_MSG is not None:
                message = settings.CAS_LOGGED_MSG % request.user.get_username()
                messages.success(request, message)
            return self.successful_login(request=request, next_page=next_page)

        ticket = request.GET.get('ticket')
        if ticket:
            user = authenticate(ticket=ticket,
                                service=service_url,
                                request=request)
            pgtiou = request.session.get("pgtiou")
            if user is not None:
                auth_login(request, user)
                if not request.session.exists(request.session.session_key):
                    request.session.create()
                SessionTicket.objects.create(
                    session_key=request.session.session_key,
                    ticket=ticket
                )

                if pgtiou and settings.CAS_PROXY_CALLBACK:
                    # Delete old PGT
                    ProxyGrantingTicket.objects.filter(
                        user=user,
                        session_key=request.session.session_key
                    ).delete()
                    # Set new PGT ticket
                    try:
                        pgt = ProxyGrantingTicket.objects.get(pgtiou=pgtiou)
                        pgt.user = user
                        pgt.session_key = request.session.session_key
                        pgt.save()
                    except ProxyGrantingTicket.DoesNotExist:
                        pass

                if settings.CAS_LOGIN_MSG is not None:
                    name = user.get_username()
                    message = settings.CAS_LOGIN_MSG % name
                    messages.success(request, message)
                return self.successful_login(request=request, next_page=next_page)
            elif settings.CAS_RETRY_LOGIN or required:
                return HttpResponseRedirect(client.get_login_url())
            else:
                raise PermissionDenied(_('Login failed.'))
        else:
            if settings.CAS_STORE_NEXT:
                request.session['CASNEXT'] = next_page
            return HttpResponseRedirect(client.get_login_url())
1286744
def create(self):
        
        self.service.create()

        predix.config.set_env_value(self.use_class, 'ingest_uri',
                self.get_ingest_uri())
        predix.config.set_env_value(self.use_class, 'ingest_zone_id',
                self.get_ingest_zone_id())

        predix.config.set_env_value(self.use_class, 'query_uri',
                self.get_query_uri())
        predix.config.set_env_value(self.use_class, 'query_zone_id',
                self.get_query_zone_id())
1180604
def page(self, value):
        

        instance = copy(self)

        instance._filters.append({
            'page': value
        })
        return instance
511162
def create_page(self, content, class_, record_keeper=None, logger=None):
        '''
        
        '''
        fields, nested_fields = separate_fields(content)

        foreign_id = content.pop('id')

        # remove unwanted fields
        if 'latest_revision_created_at' in content:
            content.pop('latest_revision_created_at')

        page = class_(**fields)

        # create functions to attach attributes
        function_args_mapping = (
            # add_section_time
            (add_json_dump, ("time", nested_fields, page)),
            # add_tags
            (add_list_of_things, ("tags", nested_fields, page)),
            # add_metadata_tags
            (add_list_of_things, ("metadata_tags", nested_fields, page)),

            # attach_image
            (attach_image, ("image", nested_fields, page, record_keeper)),
            # attach_social_media_image
            (attach_image, ("social_media_image", nested_fields,
                            page, record_keeper)),
            # attach_banner_image
            (attach_image, ("banner", nested_fields, page, record_keeper)),
        )

        for mapping in function_args_mapping:
            function = mapping[0]
            _args = mapping[1]
            try:
                function(*_args)
            except Exception as e:
                if logger:
                    logger.log(
                        ERROR,
                        "Failed to create page content",
                        {
                            "foreign_page_id": foreign_id,
                            "exception": e,
                            "function": function.__name__,
                        })

        # Handle content in nested_fields
        body = add_stream_fields(nested_fields, page)
        # body has not been added as it contains reference to pages
        if body:
            record_keeper.article_bodies[foreign_id] = body

        # Handle relationships in nested_fields
        if record_keeper:
            record_relation_functions = [
                record_keeper.record_nav_tags,
                record_keeper.record_recommended_articles,
                record_keeper.record_reaction_questions,
                record_keeper.record_related_sections,
                record_keeper.record_section_tags,
                record_keeper.record_banner_page_link,
            ]

            for function in record_relation_functions:
                try:
                    function(nested_fields, foreign_id)
                except Exception as e:
                    if logger:
                        logger.log(
                            ERROR,
                            "Failed to record content",
                            {
                                "foreign_page_id": foreign_id,
                                "exception": e,
                                "function": function.__name__,
                            })

        return page
720352
def configure_createcollection(self, ns, definition):
        
        paginated_list_schema = self.page_cls.make_paginated_list_schema_class(
            ns,
            definition.response_schema,
        )()

        @self.add_route(ns.collection_path, Operation.CreateCollection, ns)
        @request(definition.request_schema)
        @response(paginated_list_schema)
        @wraps(definition.func)
        def create_collection(**path_data):
            request_data = load_request_data(definition.request_schema)
            # NB: if we don't filter the request body through an explicit page schema,
            # we will leak other request arguments into the pagination query strings
            page = self.page_cls.from_query_string(self.page_schema(), request_data)

            result = definition.func(**merge_data(
                path_data,
                merge_data(
                    request_data,
                    page.to_dict(func=identity),
                ),
            ))

            response_data, headers = page.to_paginated_list(result, ns, Operation.CreateCollection)
            definition.header_func(headers, response_data)
            response_format = self.negotiate_response_content(definition.response_formats)
            return dump_response_data(
                paginated_list_schema,
                response_data,
                headers=headers,
                response_format=response_format,
            )

        create_collection.__doc__ = "Create the collection of {}".format(pluralize(ns.subject_name))
552824
def setup(cls):
        
        try:
            if cls.auto_setup and cls.auto_setup.get('enabled', False):
                if not cls.auto_setup.get('home title', False):
                    warnings.warn(
                        '"home title" is not set in {0}.auto_setup attribute'.format(cls)
                    )
                    return
                if not cls.auto_setup.get('page title', False):
                    warnings.warn(
                        '"page title" is not set in {0}.auto_setup attribute'.format(cls)
                    )
                    return
                if cls.app_name and not cls.auto_setup.get('namespace', False):
                    warnings.warn(
                        '"page title" is not set in {0}.auto_setup attribute'.format(cls)
                    )
                    return
                config = None
                cls._setup_pages(config)
        except Exception:
            # Ignore any error during setup. Worst case: pages are not created, but the instance
            # won't break
            pass
780791
def service(self):
        '''
        
        '''
        service_class = getattr(self, 'service_class')
        service = service_class(self.http_request)
        return service
722600
def remote_is_page_blob(self):
        # type: (Descriptor) -> bool
        
        return self.dst_entity.mode == blobxfer.models.azure.StorageModes.Page
1360432
def get_configuration(self):
        
        mapping = {}
        settings = self.get_settings()
        for record in self.context.getAnalyses():
            uid = record.get("service_uid")
            setting = settings.get(uid, {})
            config = {
                "partition": record.get("partition"),
                "hidden": setting.get("hidden", False),
            }
            mapping[uid] = config
        return mapping
619130
def to_dict(self):
        
        fields = dict(vars(self).items())

        if self.populated:
            fields['ip_addresses'] = []
            fields['storage_devices'] = []
            for ip in self.ip_addresses:
                fields['ip_addresses'].append({
                    'address': ip.address,
                    'access': ip.access,
                    'family': ip.family
                })

            for storage in self.storage_devices:
                fields['storage_devices'].append({
                    'address': storage.address,
                    'storage': storage.uuid,
                    'storage_size': storage.size,
                    'storage_title': storage.title,
                    'type': storage.type,
                })

        del fields['populated']
        del fields['cloud_manager']
        return fields
644497
def service_create(auth=None, **kwargs):
    '''
    
    '''
    cloud = get_operator_cloud(auth)
    kwargs = _clean_kwargs(keep_name=True, **kwargs)
    return cloud.create_service(**kwargs)
284797
def create(self, parameters={}, create_keys=True, **kwargs):
        
        # Create the service
        cs = self._create_service(parameters=parameters, **kwargs)

        # Create the service key to get config details and
        # store in local cache file.
        if create_keys:
            cfg = parameters
            cfg.update(self._get_service_config())
            self.settings.save(cfg)
901288
def get_storage_conn(storage_account=None, storage_key=None, opts=None):
    '''
    
    '''
    if opts is None:
        opts = {}

    if not storage_account:
        storage_account = opts.get('storage_account', None)
    if not storage_key:
        storage_key = opts.get('storage_key', None)

    return azure.storage.BlobService(storage_account, storage_key)
474130
def create(self):
        
        payload = {'type': self._type}
        if self._ddoc_id and self._ddoc_id != '':
            if isinstance(self._ddoc_id, STRTYPE):
                if self._ddoc_id.startswith('_design/'):
                    payload['ddoc'] = self._ddoc_id[8:]
                else:
                    payload['ddoc'] = self._ddoc_id
            else:
                raise CloudantArgumentError(122, self._ddoc_id)
        if self._name and self._name != '':
            if isinstance(self._name, STRTYPE):
                payload['name'] = self._name
            else:
                raise CloudantArgumentError(123, self._name)
        self._def_check()
        payload['index'] = self._def

        if self._partitioned:
            payload['partitioned'] = True

        headers = {'Content-Type': 'application/json'}
        resp = self._r_session.post(
            self.index_url,
            data=json.dumps(payload, cls=self._database.client.encoder),
            headers=headers
        )
        resp.raise_for_status()
        self._ddoc_id = response_to_json_dict(resp)['id']
        self._name = response_to_json_dict(resp)['name']