I have few A records in my Route53 Account. I want to bulk update the TTL for all of them.
The logic I'm using is that I get all the records using "ListResourceRecordSets" operation. Create following change object for each record.
array(
'Action' => 'UPSERT',
'ResourceRecordSet' => array(
'Name' => OLD_CNAME,
'Type' => 'A',
'TTL' => NEW_TTL,
'ResourceRecords' => array(array(
'Value' => OLD_IP
)),
));
Then I send a "ChangeResourceRecordSets" request with change objects created in last step.
Route53 is returning this error Validation errors: [ChangeBatch][Changes][0][Change][Action] must be one of "CREATE" or "DELETE" [ChangeBatch][Changes][1][Change][Action] must be one of "CREATE" or "DELETE" )
P.S. I couldn't find any UPSERT example for ChangeResourceRecordSets call.
Either update your AWS SDK to a later version that supports UPSERT or You first have to delete the record set(s) and then add them with the new changes.
UPSERT was added in early 2014: https://aws.amazon.com/blogs/aws/new-features-for-route-53-improved-health-checks-https-record-modification/
So you must have a really old SDK.
To do it without UPSERT:
array(
'Action' => 'DELETE',
'ResourceRecordSet' => array(
'Name' => OLD_CNAME,
'Type' => 'A',
'TTL' => OLD_TTL,
'ResourceRecords' => array(array(
'Value' => OLD_IP
)),
));
and then:
array(
'Action' => 'CREATE',
'ResourceRecordSet' => array(
'Name' => OLD_CNAME,
'Type' => 'A',
'TTL' => NEW_TTL,
'ResourceRecords' => array(array(
'Value' => OLD_IP
)),
));
Related
I'm trying to retrieve a report from the AdExchange Seller API.
I am using the maximum allowed amount of dimensions and metrics so the reports is quite big (>100.000 rows). According to the documentation on large reports this is possible using the limit break feature by adding the alt=media parameter. But I can't figure out how to add that parameter using the Google API client for PHP. I would prefer to stick to the official Google libraries, but I'm open for suggestions.
Note: adding alt=csv or alt=media to the optParams does not work and I can easily access the data if I remove some of the dimensions and metrics.
More specifically I'm using the accounts_reports resource and then the generate method. Looking at the source code (shown below), I can't see anywhere that it would be able to accept a alt parameter, but I'm obviously missing something.
$this->accounts_reports = new Google_Service_AdExchangeSeller_Resource_AccountsReports(
$this,
$this->serviceName,
'reports',
array(
'methods' => array(
'generate' => array(
'path' => 'accounts/{accountId}/reports',
'httpMethod' => 'GET',
'parameters' => array(
'accountId' => array(
'location' => 'path',
'type' => 'string',
'required' => true,
),
'startDate' => array(
'location' => 'query',
'type' => 'string',
'required' => true,
),
'endDate' => array(
'location' => 'query',
'type' => 'string',
'required' => true,
),
'dimension' => array(
'location' => 'query',
'type' => 'string',
'repeated' => true,
),
'filter' => array(
'location' => 'query',
'type' => 'string',
'repeated' => true,
),
'locale' => array(
'location' => 'query',
'type' => 'string',
),
'maxResults' => array(
'location' => 'query',
'type' => 'integer',
),
'metric' => array(
'location' => 'query',
'type' => 'string',
'repeated' => true,
),
'sort' => array(
'location' => 'query',
'type' => 'string',
'repeated' => true,
),
'startIndex' => array(
'location' => 'query',
'type' => 'integer',
),
),
),
)
)
);
Digging further I found this statement in the Google_Service_AdExchangeSeller_Resource_AccountsReports class.
Generate an Ad Exchange report based on the report request sent in the query
parameters. Returns the result as JSON; to retrieve output in CSV format
specify "alt=csv" as a query parameter. (reports.generate)
But how exactly would that work? As far as I can figure out, it doesn't.
Not really an answer but to long for a comment.
I don't think you are going to get that to work with the client library. The client libraries are generated via the Discovery Services API. Which gives information about what parameters the API takes. For some reason this alt=csv is not registered in the discovery services for that API. Its there in the description but its not registered as a parameter. So the Client library itself isn't going to build it for you.
You can see the response I am looking at here
An idea would be to make the change to the client library yourself you have the code. While altering the client libraries manually is not ideal it is doable.
Try and add alt and give it a value of CSV.
I don't have enough experience with the inner workings of the PHP client library but you can post this as an issue on their forum. Mention that its not in discovery they may have an easer way of applying a random parameter to the query string. I doubt it but its worth a shot.
This should be possible with the PHP client library. The following example demonstrates how to do it with the Drive API:
$fileId = '0BwwA4oUTeiV1UVNwOHItT0xfa2M';
$content = $driveService->files->get($fileId, array(
'alt' => 'media' ));
https://developers.google.com/drive/v3/web/manage-downloads#examples
$options = array(
'UserData' => base64_encode('test'),
'SecurityGroupIds' => [AWS_REGIONS[$region]['security_group']],
'InstanceType' => AWS_REGIONS[$region]['instance_type'],
'ImageId' => AWS_REGIONS[$region]['ami'],
'MaxCount' => $to_launch,
'MinCount' => 1,
//'EbsOptimized' => true,
'SubnetId' => AWS_REGIONS[$region]['subnet_id'],
'Tags' => [['Key' => 'task', 'Value' => $task],['Key' => 'Name', 'Value' => $task]],
'InstanceInitiatedShutdownBehavior' => 'terminate'
);
$response = $client->runInstances($options);
I am using the "latest" Ec2Client
It launches fine but the Tags are completely ignored.
I suspect an error within the EC2 API but I am not that experienced.
Maybe someone with experience can help me out ?
This is because Ec2Client::runInstances does not have tags option
http://docs.aws.amazon.com/aws-sdk-php/v3/api/api-ec2-2015-10-01.html#runinstances
You would need to make a separate call to tag newly created instance(s) using Ec2Client::createTags:
$result = $client->createTags(array(
'DryRun' => true || false,
// Resources is required
'Resources' => array('string', ... ),
// Tags is required
'Tags' => array(
array(
'Key' => 'string',
'Value' => 'string',
),
// ... repeated
),
));
Read more here:
http://docs.aws.amazon.com/aws-sdk-php/v3/api/api-ec2-2015-10-01.html#createtags
In my web application I use tabs and load part of the views per Ajax. So it's possible, that I do load the same CGridView multiple times without reloading the page. If that occurs I become duplicate Ajax requests if I use CGridView Filters.
The filters and requests are standard. Following images show those simple filter and 10 GET requests if type the search value once.
Here is the code of Tabs-widget I use:
$this->widget('bootstrap.widgets.TbTabs', array(
'id' => 'thirdPartyCatTabs',
'title' => Translate::t('project', 'Categories'),
'type' => 'tabs',
'placement' => 'top',
'events' => array(
'shown' => 'js:loadContent'
),
'tabs' => array(
array(
'id' => 'standardCat',
'label' => Translate::t('project', 'Standard Categories'),
'linkOptions' => array(
'data-tab-url' => Yii::app()->createUrl('/thirdParty/settings/thirdPartyCategoryStandard'),
),
),
array(
'id' => 'standardCatMap',
'label' => Translate::t('project', 'Standard Category-Mapping'),
'linkOptions' => array(
'data-tab-url' => Yii::app()->createUrl('/thirdParty/settings/showCategoryMapTab'),
),
),
)
));
I guess I have to use uniqid() at some place, but can't figure out where.
Thanks.
I'm trying to create a record set with the aws sdk and I'm getting this validation error:
Validation errors: [ChangeBatch][Changes][0][Change][ResourceRecordSet][ResourceRecords][Value][ResourceRecord] must be of type object
My code looks like this:
$result = $r53->changeResourceRecordSets(array(
'HostedZoneId' => 'XXXXXXXXXXXXXXX',
'ChangeBatch' => array(
'Changes' => array(
array(
'Action' => 'CREATE',
'ResourceRecordSet' => array(
'Name' => 'psion',
'Type' => 'CNAME',
'ResourceRecords' => array(
'Value' => 'example.com'
),
),
'Change' => array(
'ResourceRecordSet' => array(
'ResourceRecords' => array(
'Value' => array(
'ResourceRecord' => $aws->get('Route53'),
),
),
),
),
),
),
),
));
Any idea what the validation error means?
Validation errors: [ChangeBatch][Changes][0][Change][ResourceRecordSet][ResourceRecords][Value][ResourceRecord] must be of type object.
By type "object", it means an associative array. This is a validation message bubbling up from the Guzzle layer.
Here are the API docs for Route53Client::changeResourceRecordSets(), which shows an example of how the request should look when it is formatted correctly.
That whole array you have under the 'Change' key is not correct at all.
I am trying to validate a multiply select using input filter, but every time I see a error. The error is "notInArray":"The input was not found in the haystack".(I use ajax but it doesn`t metter).
I will show part of my code to be more clear.
in Controller:
if ($request->isPost()) {
$post = $request->getPost();
$form = new \Settings\Form\AddUserForm($roles);//
$form->get('positions')
->setOptions(
array('value_options'=> $post['positions']));
//.... more code...
When I put print_r($post['positions']); I see:
array(0 => 118, 1 => 119)
in ..../form/UserForm.php I create the multiply element
$this->add(array(
'type' => 'Zend\Form\Element\Select',
'attributes' => array(
'multiple' => 'multiple',
'id' => 'choosed_positions',
),
'required' => false,
'name' => 'positions',
));
and in the validation file the code is:
$inputFilter->add($factory->createInput(array(
'name' => 'positions',
'required' => false,
'validators' => array(
array(
'name' => 'InArray',
'options' => array(
'haystack' => array(118,119),
'messages' => array(
'notInArray' => 'Please select your position !'
),
),
),
),
What can be the reason every time to see this error, and how I can fix it?
By default selects have attached InArray validator in Zend Framework 2.
If you are adding new one - you will have two.
You should disable default one as follow:
$this->add(array(
'type' => 'Zend\Form\Element\Select',
'options' => array(
'disable_inarray_validator' => true, // <-- disable
),
'attributes' => array(
'multiple' => 'multiple',
'id' => 'choosed_positions',
),
'required' => false,
'name' => 'positions',
));
And you should get rid of the additional error message.
Please let us know if that would helped you.